Skip to Content

Bind sap.m.StandardListItem "Selected" Property from odata boolean Result "X"

I was trying to bindItems in a sap.m.List of sap.m.StandardListItem, but was not able to make sap.m.ListMode.MultiSelect selected if one parameter is coming "X". In filter if we use this boolean check then false results will not be shown in output. To show in a Dialog the list with selected StandardListItem, I used bindProperty and it works. Here is my code example:

Code Snippet

var itemTemplate = new sap.m.StandardListItem({

title : "{SrvTaskDesc}", // string

});

itemTemplate.bindProperty("selected", "IsenbDisInd", function(bValue) {

return bValue == "X" ? true : false;

});

retMethList = new sap.m.List({

mode : sap.m.ListMode.MultiSelect,

});

url = location.protocol+"//"+dynamicHost+":"+dynamicPort+"/sap/opu/odata/XXX/XXXXXXX/";

oModel = new sap.ui.model.odata.ODataModel(url, true);

retMethList.setModel(oModel);

params = ",C" + ","

+ sap.ui.getCore().getModel("userModel").getData().plant + ",,,,"

+ "";

filter = new sap.ui.model.Filter("IAllparam", sap.ui.model.FilterOperator.EQ, params);

retMethList.bindItems("/getGlobalTaskList",itemTemplate,null,[filter]);

new sap.m.Dialog({

title : "Sanjoy Saha", // string

content : retMethList, // sap.ui.core.Control

leftButton : new sap.m.Button({

text : "CANCEL",

type : sap.m.ButtonType.Reject,

icon : sap.ui.core.IconPool

.getIconURI("sys-cancel"),

press : function() {

this.getParent().close();

}

}),

rightButton : new sap.m.Button({

text : "SAVE",

type : sap.m.ButtonType.Accept,

icon : sap.ui.core.IconPool.getIconURI("save"),

press : function() {

this.getParent().close();

}

}),

afterClose : [ function(oEvent) {

var control = oEvent.getSource();

}, this ]

}).open();

Here IsenbDisInd is the field which is coming from odata as "X" or "" as output and based on that ListItem is selected or deselected.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jan 16, 2016 at 02:35 PM

    Will this helpful for you? https://jsbin.com/xaketa/edit?html,js,output

    //Code:

    //Model

    var data = [{

    "title" : "SSE",

    "selected" : "X"

    },

    {

    "title" : "SE",

    "selected" : "Y"

    }];

    var model = new sap.ui.model.json.JSONModel(data);

    sap.ui.getCore().setModel(model);

    //Control

    var itemTemplate = new sap.m.StandardListItem({

    title : "{title}",

    selected : {

    path : "selected",

    formatter : function(oEvent){

    return oEvent=="X" ? true : false;

    }

    }

    });

    var retMethList = new sap.m.List({

    mode : sap.m.ListMode.MultiSelect

    });

    retMethList.bindItems("/",itemTemplate);

    retMethList.placeAt("content");

    Regards,

    Karthik A

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.