Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Bind data to table using filter

tab.bindItems("/OrdItabSet", tab, null, oFilters);

I am developing a table and while binding data to it in need to apply filter my code is as below

XML code

<Table id="idProductsTable"  rows="{/OrdItabSet}" >

                <columns>

                    <Column>

                        <Label text="Employee Number" />

                    </Column>

                    <Column>

                        <Label text="Employee Name" />

                    </Column>

                    <Column>

                        <Label text="Default Password" />

                    </Column>

                </columns>

                <items>

                        <Input value ="{OrdItab/Order}"></Input>

                        <Input value="{OrdItab/Order}"></Input>

                        <Input value="{OrdItab/Order}"></Input>

                   

                    </ColumnListItem>

                </items>

            </Table>

JS code

var tab = this.getView().byId("idProductsTable");

var oFilters = [ new sap.ui.model.Filter("CustId","EQ", "'"+custId+"'") ];

tab.bindItems("/OrdItabSet", tab, null, oFilters);

But its showing no data.

Former Member
Former Member replied

See highlighted changes

JS Code:

var table = this.getView().byId("idProductsTable");

var oBinding = table.getBinding("items");

var oFilters = [ new sap.ui.model.Filter("CustId",sap.ui.model.FilterOperator.EQ, "'"+custId+"'") ];

oBinding.filter(oFilters);

XML

<m:Table

  items="{OrdItab/OrdItabSet}"

  title="Products"

  selectionMode="MultiToggle"

  visibleRowCount="7"

  id="idProductsTable">

  <columns>

  <Column width="9rem">

  <m:Label text="{OrdItab/Order}" />

  </Column>

  <Column width="9rem">

  <m:Label text="{OrdItab/Orderdt}" />

  </Column>

  <Column width="9rem">

  <m:Label text="{OrdItab/Orderdt}" />

  </Column>

  <Column width="9rem">

  <m:Label text="{OrdItab/Orderdt}" />

  </Column>

  <Column width="9rem">

  <m:Label text="{OrdItab/Orderdt}" />

  </Column>

  <Column width="12rem">

  <m:Label text="{OrdItab/Orderdt}" />

  </Column>

  </columns>

<items>

   <ColumnListItem>  

     <cells>

                <Link text="{user}" >

                </Link>

                <!-- etc -->

            </cells>

        </ColumnListItem>

    </items>

</m:Table>

You have to add items aggregation to your table in the red marked line. In this aggregation don't forget to add as many cells as you need!

I also noticed that you have not chosen sap.m as your default library in the XML definition since you use <m:Label text="{OrdItab/Orderdt}" /> to create another mobile Label. You would also have to add this m in front of your table if you want to use sap.m table. I've done this and highlighted it as well.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question