cancel
Showing results for 
Search instead for 
Did you mean: 

How to use filter in ui5 table

0 Kudos
17,801

Hi,

I am  trying to use filter but after clicking in button event all the data are coming. It is not filtering any  data..

var oModel = this.getView().getModel();

  var oIn1 = this.getView().byId("in1").getValue(); 

   var oTable = this.getView().byId("Tab2");

      oTable.addColumn(new sap.ui.table.Column({

           label : new sap.m.Label({ text : "MaterialNo"}),

           template : new sap.m.Text({ text : "{MaterialNo}", filterProperty:aFilter  }),

           }

       ));

       oTable.addColumn(new sap.ui.table.Column({

           label : new sap.m.Label({ text : "SalesOrderNo" }),

           template : new sap.m.Text({ text : "{SalesOrderNo}", filterProperty:aFilter }),

           }

       ));

       oTable.getBinding("rows").filter([aFilter]);

       //Filter values for a certain Sales Number

       var aFilter=new sap.ui.model.Filter( "SalesOrderNo", sap.ui.model.FilterOperator.Contains, oIn1) ;

      

       oTable.bindRows({ path: "/MaterialNode", filters: [aFilter], });

  }

Thanks..

View Entire Topic
karthikarjun
Active Contributor

Hi Anupam,

oTable.addColumn(new sap.ui.table.Column({

           label : new sap.m.Label({ text : "MaterialNo"}),

           template : new sap.m.Text({ text : "{MaterialNo}", filterProperty:aFilter  }),

           }

       ));

aFilter - give your model property name.


Examples are already available here: Table - SAPUI5 Demo Kit


Thanks,

Karthik A


0 Kudos

Hi Katthik ,

a have already used that one .. but it is not working for me..

vijay_kumar49
Active Contributor
0 Kudos

as you told you are using XML View. but you pasted the code here javascript code.

please check.

any way if you are using xml view. please check this code: SAPUI5 Explored

Romesh
Associate
Associate
0 Kudos

In my case, I was using `filterProperty` value incorrectly. I was using `template>name` but correct value required was only `name`.