Deepak
Deepak

Reputation: 493

Filtering customListItem in sap.m.List

I am stuck with a weird issue with filtering. When I use a Standard List Item, the below works perfectly

new sap.ui.model.Filter(path,operator,value)

But when I use customlistItem it stops working. I am using below code for filtering.

var list = sap.ui.getCore().byId("listToFilter");
var binding = list.getBinding("items");
var filter = new sap.ui.model.Filter("Description",sap.ui.model.FilterOperator.Contains , value);
binding.filter(filter,"Application"); binding.refresh(true);

I have a checkBox whose text field is bound to the property I am Passing in the Filter Path

var checkBox = new sap.m.CheckBox({                      
                 text: "{Description}",
                 selected:"{path: 'Selected', type:'sap.ui.model.type.String'}"
});

Appreciate any advices on how to acheive this.

Upvotes: 0

Views: 2547

Answers (1)

Sarath Chandra
Sarath Chandra

Reputation: 189

I have replicated your scenario and it is perfectly working fine for me.
Below is some sample code.

**view:**
  <List
    headerText="Custom Content"
    id="IDCustomerListItem"
    items = "{oAppView>/modelData}">
    <CustomListItem type="Inactive">
               <CheckBox text="{oAppView>lastName}" selected="true" />
    </CustomListItem>
  </List>

**Controller**:
            var list,
            binding,
            filter;
            list = this.getView().byId("IDCustomerListItem");
            filter = new sap.ui.model.Filter("lastName",sap.ui.model.FilterOperator.Contains , "D");
            binding = list.getBinding("items");
            binding.filter(filter,"Application");
            binding.refresh(true);

Upvotes: 3

Related Questions