0
votes

XML View

<List id="facebookList" items="{/}" mode="MultiSelect"  selectionChange="onSelectionChange">
    <StandardListItem type="Navigation" title="{account_name}" icon="{photo}" iconDensityAware="false" iconInset="false"/>
</List>

I have a list of items and checkboxes. When I click on checkbox, I want to take the value of checkbox in js controller. How to do this in sap fiori UI5

3

3 Answers

0
votes

In the implementation of onSelectionChange method in the controller you can get the list item selected value as below,

onSelectionChange: function(oEvent) {
    var selected = oEvent.getParameter("selected");
    var selectedItem = oEvent.getParameter("listItem");
    // ...
}

FYI, see this API selectionChange method

0
votes

implement onSelectionChange method in your control

onSelectionChange:function(oEvent){
    var selected = [];
 var parameter = oEvent.getParameters();
            if(parameter.listItem){
                var item = parameter.listItem.getBindingContext().getObject();

                if(item.selected){
                    selected.push(item);
                }else{
                    selected.splice(selected.indexOf(item), 1);

                }
}
0
votes
onSelectionChange:function(oEvent){
    console.log(oEvent.getParameters().selectedItem);
}

you will find the value in mProperties.