Skip to Content
0

Bind the dynamic populated JS array from controller to its xml view list

Apr 05, 2017 at 07:04 PM

19

avatar image

Hello everyone,

My model has an entity set that has properties: processNumber(key) and UsecaseId. I want to get the count of processes for each Usecase ID.

My expected output is :

Usecase1 : 20

Usecase2 : 30

and so on... And finally it is to be displayed as pie chart.

This is the initial code I started with. And later I had no clue how to bind the array from my controller to view.

Thanks in advance.

Regards Divya

onInit: function() {
var oModel = this.getOwnerComponent().getModel("NewDE4");
oModel.disableHeadRequestForToken = true;

var processStatusFilter = new sap.ui.model.Filter("ProcessStatus", sap.ui.model.FilterOperator.EQ, "04");
oModel.read("/processSet", {
filters: [processStatusFilter],
method: "GET",
success: function(oData) {

var fld = oData.results;
var value = [];
for (var i = 0; i < oData.results.length; i++) {
var json = {};
json.ProcessGuid = fld[i].ProcessGuid;
json.UseCaseId = fld[i].UseCaseId;
value.push(json);

}
var oViewModel = new sap.ui.model.json.JSONModel(json);
this.getView().setModel(oViewModel);

},
error: function() {
alert("Error reading oData");
}
});

}
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers