cancel
Showing results for 
Search instead for 
Did you mean: 

how to use filter in a table using Odata service!!

Former Member
0 Kudos

Hi Experts

     I am using using Odata service in a table and i want to get filtered data in table using odata service.

but it is not working.  Please help me out.

Please also check the code below:


     var openTable = new sap.m.Table({

       id: "openTable" ,

       columns: [

       new sap.m.Column({

       width: "20%",

       header: new sap.m.Label({

       text: "Description" 

        })

       }),

       new sap.m.Column({

       width: "20%",

       header: new sap.m.Label({

       text: "Order Quantity"

        })

       }),

       new sap.m.Column({

       width: "20%",

       header: new sap.m.Label({

       text: "Price"

       })

       }),

      

       new sap.m.Column({ 

       width: "20%",

       header: new sap.m.Label({

       text: "Net Amount"

       })

       }),

       new sap.m.Column({ 

           width: "20%",

           header: new sap.m.Label({

           text: "Status Summary"

           })

           }),

           new sap.m.Column({ 

               width: "20%",

               header: new sap.m.Label({

               text: "Shipped"

               })

               }),

         ]

       });

    

     debugger;

     var    templ = new sap.m.ColumnListItem({

    id: "ite",

        type: "Navigation",

        visible: true,

        cells: [

             

               new sap.m.Label({

               text: "Description",

               design : "Bold"

                 }),

               new sap.m.Label({

               text: "{Ordered}"

               }),

               new sap.m.Label({

               text: "{Price}"

                    }),

               new sap.m.Label({

               text: "{Amount}"

                

               }),

               new sap.m.Text().bindProperty("text","StatusSummery",function(id){

                  

                   if(id == "Shipped")

                    {

                    this.addStyleClass("green");

                      }

                          else if(id=="Open"){

                    this.addStyleClass("red");

                    }

                    else if(id == "In Process")

                    {

                    this.addStyleClass("yellow");

                  

                    }

                    return id;

                    }

                     ),                   

                   

                   

           new sap.m.Label({

           text: "{Shipped}"

           }),

           ]

              

    

     });

     debugger;

     var f1 = new  sap.ui.model.odata.Filter('StatusSummery', sap.ui.model.FilterOperator.EQ, "Open"); 

     openTable.bindAggregation("items","/data2",templ,f1 );

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

Hi Vishnu,

Try like this and check:


var f1 = new  sap.ui.model.Filter('StatusSummery', "EQ" , "Open");

openTable.bindAggregation("items",{path:"/data2", template:templ, filters:f1});

Also check the spelling, I guess it should be "StatusSummary"


Regards,

Sai Vellanki.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Check this link for ref: