on 03-20-2017 2:00 PM
Hi experts,
I need to make a sort from WorkCenterID. I already try a lot of ways, but I don´t have a good result.
configureSelectBox: function () {
var i=0;
var params = this.getPageParamsFromInputModel();
var select = this.getView().byId("workCenterSelect");
var oInputModel = this.getView().getModel("input");
var workCenterName=[];
oInputModel.setProperty("/WorkCenterID", params.workCenterID);
var oProductionModel = this.getModel(this.constants.MODELS.PRODUCTION);
console.log(oProductionModel.oData);
for (u in oProductionModel.oData){
if (typeof oProductionModel.oData[u].WorkCenterName != "undefined") {
if (oProductionModel.oData[u].WorkCenterName !=""){
workCenterName[i]=[oProductionModel.oData[u].WorkCenterID, oProductionModel.oData[u].WorkCenterName, oProductionModel.oData[u].Description];
i++;
}
}
}
if (workCenterName!=""){
localStorage.setItem('workCenterName', JSON.stringify(workCenterName));
}
select.setModel(oProductionModel);
select.bindItems({
path: '/CellSet',
template: new sap.ui.core.Item({
key: '{WorkCenterID}',
text: '{Description}'
}),
sorter: [new sap.ui.model.Sorter("WorkCenterID",false,false, function (a, b) {
if (parseInt(a.WorkCenterID) > parseInt(b.WorkCenterID)) {
return 1;
console.log(a.WorkCenterID);
}
else if (parseInt(a.WorkCenterID) < parseInt(b.WorkCenterID))
{
console.log(b.WorkCenterID);
return -1;
}
return 0;
})],
filters: [new sap.ui.model.Filter([
new sap.ui.model.Filter('LanguageID', sap.ui.model.FilterOperator.EQ, params.languageID),
new sap.ui.model.Filter('WorkCenterID', sap.ui.model.FilterOperator.NE, '00000000'),
new sap.ui.model.Filter('LayoutID', sap.ui.model.FilterOperator.EQ, params.layoutID)
], true)]
});
},
Someone can help me!
what's the version of your odata model? usually sort happens at server side for old odata model.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Try using odata call. Enhance your oData method for sorting then you can easily sort.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi André,
Use the orderby attribute for the odata protocol from here:
http://services.odata.org/OData/OData.svc/Products?$orderby=Rating
This will bring data from this service for all Product Entries returned in ascending order when sorted by the Rating Property.
Regards,
Ivan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.