Skip to Content
0
Jul 26, 2016 at 11:33 AM

Applying Group By in sap.m.table Which Consumes OData Service

3223 Views

Hi,

I am using sap.m.table and showing data by calling Odata service. I have to apply Group By on table. I have used ViewSettingsDialog. Below is code for confirm even of ViewSettingsDialog:

onGroupConfirm: function(oEvent){

var parameters = oEvent.getParameters();

var sPath = parameters.groupItem.getKey();

var bDescending = parameters.sortDescending;

var aSorters = [];

var vGroup = function(oContext) {

var name = oContext.getProperty(sPath);

return {

key: name,

text: name

};

};

aSorters.push(new sap.ui.model.Sorter(sPath, bDescending, vGroup));

oDataModel.read("/Ztest_Purchaseorder?$skip=0&$top=20", {sorters: aSorters, success: function(oData, response){

var jsonResult = JSON.parse(response.body);

if(jsonResult && jsonResult.d){

oJSONModel.setData(jsonResult.d);

}else{

oJSONModel.setData(response.body);

}

}});

}

It is not working. Could you suggest what is wrong?

Regards,

Vinayak.