on 12-11-2017 12:52 PM
I'm trying to get data in java servlet but when I get new data from the servlet, it's overwriting the existing model. May I bind more json model to my view and how will I do this ?
sap.ui.define( [ "jquery.sap.global", "sap/ui/core/Fragment",
"sap/ui/core/mvc/Controller", "sap/ui/model/Filter",
"sap/ui/model/json/JSONModel" ], function(jQuery, Fragment, Controller,
Filter, JSONModel) {
"use strict";
return Controller.extend("sap.ui.demo.wt.controller.Form", {
onInit : function() {
this.getData();
var data = {
material_unit : [],
material : []
};
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(data);
sap.ui.getCore().setModel(oModel);
},
getData : function() {
$.ajax( {
data : "",
type : "post",
dataType : "json",
async : false,
contentType : "application/json; charset=UTF-8",
url : "/material_process/OperationServlet?action=UNIT",
success : function(returnData) {
var material_unit = new sap.ui.model.json.JSONModel();
material_unit.setSizeLimit(returnData.length);
material_unit.setData( {
units : returnData
});
sap.ui.getCore().setModel(material_unit);
},
error : function(jqXHR, textStatus, errorThrown) {}
});
},
handleLiveChange : function(oEvent) {
var value = oEvent.getParameter("value");
$.ajax( {
data : "",
type : "post",
dataType : "json",
async : false,
contentType : "application/json; charset=UTF-8",
url : "/material_process/OperationServlet?action=MATSEARCH-"+ value,
success : function(returnData) {
var material = new sap.ui.model.json.JSONModel();
material.setData( {
materials : returnData
});
sap.ui.getCore().setModel(material, "material");
},
error : function(jqXHR, textStatus, errorThrown) {}
});
}
});
});
Hi Serdar Yazıcı,
You can use any number of models in your view with the help of different aliases.
this.getView().setModel(oModel,"Your_Alias_Name");
Regards,
Arjun Biswas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the issue you are having is bc you are binding the entire data model w the new data set, instead, you should add the data set to a model property - then get/set it... if you need to add more properties, then "set" the new property and its value. if you google... add property to json model you'll find a lot of examples
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.