on 10-23-2015 7:36 AM
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.
If you are trying to use a sap.ui.table you can try the following:
<Table id="idProductsTable" rows="{/OrdItabSet}" >
<columns>
<Column>
<Label text="Employee Number" />
<template>
<Label text={rowPropertyEmployeeNumber} />
</template>
</Column>
<Column>
<Label text="Employee Name" />
<template>
<Label text={rowPropertyEmployeeName} />
</template>
</Column>
<Column>
<Label text="Default Password" />
<template>
<Label text={rowPropertyDefaultPassword} />
</template>
</Column>
</columns>
</Table>
With this you should get at least a normal table to work. Now for the filter side of things:
var tab = this.getView().byId("idProductsTable");
var oBinding = table.getBinding("rows");
var oFilters = [ new sap.ui.model.Filter("CustId",sap.ui.model.FilterOperator.EQ, "'"+custId+"'") ];
oBinding.filter(oFilters);
This should apply the filters to the binding. Notice that i have used a constant provided by the ui5 library called sap.ui.model.FilterOperator.EQ. If you want to remove the filter simply put an empty array to the binding. Now it's up to you to implement this and tell us if everything works well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Somebody explained a sap.m.table already in this thread. Can you try that? Does it solve your problem?
How about this:
Hi dirk,
I tried your code its showing canont read the property "filter" of undefined.
var table = this.getView().byId("idProductsTable");
var oBinding = table.getBinding("rows");
var oFilters = [ new sap.ui.model.Filter("CustId",sap.ui.model.FilterOperator.EQ, "'"+custId+"'") ];
oBinding.filter(oFilters);
<Table | ||||
rows="{/OrdItabSet}" | ||||
title="Products" | ||||
selectionMode="MultiToggle" | ||||
visibleRowCount="7" | ||||
id="idProductsTable"> |
Hi,
Please mention "items" instead "rows" if you are using sap.m.Table.
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);
Regards,
Rumeshbabu S
sorry for confusion.I will explain it again.now m trying like this but for
var oBinding = table.getBinding("rows"); |
OBinding its showing is undefined.
my js code is as below
var table = this.getView().byId("idProductsTable");
var oBinding = table.getBinding("rows");
var oFilters = [ new sap.ui.model.Filter("CustId",sap.ui.model.FilterOperator.EQ, "'"+custId+"'") ];
oBinding.filter(oFilters);
and XML code is
<Table
rows="{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>
</Table>
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.
Hi Sham,
Check this sample: JS Bin - Collaborative JavaScript Debugging
Provide weight value which exists in the table for the input which is placed at the bottom. For example provide input value as 103 it will filter the item with weight as 103.
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sham,
.bindItem("/items", oItem, null, [oFilter2]) is not supported in OpenUI5. Ref: https://github.com/SAP/openui5/issues/130
Check weather you are using openUI5.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sham,
Which library does the table control belongs to? Since, your code says in XML view as rows="{}" and in the JS code as .bindItems() ? For table commons, there are rows and mobile table there are items.
And one more thing, custId value is user input / is it dynamic?
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sham,
No need to bind the items again. You can apply filter to the table binding Data like this -
var oTable = this.getView().byId("idProductsTable");
var custId = +your cutomer ID value+; //Get your Customer ID value into a variable
var oFilters = new sap.ui.model.Filter("CustId", "EQ", custId);
oTable.getBinding("items").filter(oFilters, "Application");
Regards,
Sai Vellanki.
Hi sai,
thanks. But now problem is that i am passing items like this
<Table id="idProductsTable" items="{/OrdItabSet}">
and application is only keep loading not showing any screen.
Beacuse wen m runnig /sap/opu/odata/SAP/ZCUST_FABT_SHEET_SRV/OrdItabSet in segw without filter its not showing anything with filter its showing output in segw.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.