Skip to Content
avatar image
Former Member

select sort sapui5

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);
	        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];
	    if (workCenterName!=""){    
	    	localStorage.setItem('workCenterName', JSON.stringify(workCenterName));
            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;
                else if (parseInt(a.WorkCenterID) < parseInt(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!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Mar 20, 2017 at 03:13 PM

    what's the version of your odata model? usually sort happens at server side for old odata model.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 20, 2017 at 01:43 PM

    Hi André,

    Use the orderby attribute for the odata protocol from here:$orderby=Rating

    This will bring data from this service for all Product Entries returned in ascending order when sorted by the Rating Property.


    Add comment
    10|10000 characters needed characters exceeded

  • Nov 10, 2018 at 12:29 PM


    Try using odata call. Enhance your oData method for sorting then you can easily sort.

    Add comment
    10|10000 characters needed characters exceeded