on 07-28-2016 10:31 PM
Hi Experts,
I am using a list control for master detail template and successfully binded Entityset fields to display in list.
Now how can use filter query and bind it to list control.
/sap/opu/odata/SAP/MYNEWSERVICE_SRV_02/SalesDetailSet?$filter= Soldtoparty eq '100'
the filter query results with multiple values which are to be binded. to List control. Currently SalesDetailSet all values are binded to list.
Are there any sample code to use as reference, please suggest.
Thanks in advance
Kumar
here u go
<table:Table rows="{
path: '/table',
filters: [{
path: 'field3',
operator: 'EQ',
value1: 'test'
}],
sorter: [{
path: 'field1',
descending: false
}, {
path: 'field2',
descending: true
}]
}">
...
</table:Table>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How do i pass it dynamically instead of hardcoding?
path: 'field3',
operator: 'EQ',
value1: 'test'
the 'test' value comes from a dialog.fragment.xml list ? the fragment code is as below.
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core">
<SelectDialog
noDataText="No Data Found"
title="Select Sales Org"
search="handleSearch"
confirm="handleClose"
cancel="handleClose"
items="{
path: '/F4_SalesOrganizationSet'
}"
>
<StandardListItem
title="{Vkorg}"
description="{Vtext}"
type="Active" />
</SelectDialog>
</core:FragmentDefinition>
handle close function of fragment
handleClose: function(oEvent) {
var aContexts = oEvent.getParameter("selectedContexts");
if (aContexts.length)
{ sap.m.MessageToast.show("You have chosen Sales Organization" + aContexts.map(function(oContext) { return oContext.getObject().Vkorg; }).join(", "));
});
List Code in Master Page
Currently the filter is hardcoded , but the value is to be collected from the fragment list and filtered upon the list and binded in master page.
filters: [{ path: 'Salesorganization', operator: 'EQ', value1: '2000' }],
<List
id="list"
items="{ path: '/CustomersListSet',
filters: [{ path: 'Salesorganization', operator: 'EQ', value1: '002' }],
sorter: { path: 'Soldtoparty', descending: false },
groupHeaderFactory: '.createGroupHeader' }"
busyIndicatorDelay="{masterView>/delay}"
noDataText="{masterView>/noDataText}"
mode="{= ${device>/system/phone} ? 'None' : 'SingleSelectMaster'}"
growing="true" growingScrollToLoad="true"
updateFinished="onUpdateFinished"
selectionChange="onSelectionChange">
<infoToolbar>
<Toolbar active="true" id="filterBar" visible="{masterView>/isFilterBarVisible}" press="onOpenViewSettings">
<Title id="filterBarLabel" text="{masterView>/filterBarLabel}"/>
</Toolbar> </infoToolbar>
<items>
<ObjectListItem type="{= ${device>/system/phone} ? 'Active' : 'Inactive'}" p
ress="onSelectionChange" title=" {Customername} ({Soldtoparty})">
<firstStatus>
<ObjectStatus text="Salesorganization: {Salesorganization}"/> </firstStatus>
<attributes></attributes> </ObjectListItem> </items>
</List>
As suggested by others and noted here at github it is not possible right now to have dynamic filtering in XML views.
As also suggested try pass the filters during binding in controller file.
BR.
Ankit, Jagadessh,
Can you please suggest any code snippet for this.
I came across a similar requirement in a thread Dynamic OData filter in sap.m.List (XML View) | SCN but trying to allign with my requirement .
Please suggest via a code snippet
Hi Kumar,
I think the link u provided contains the solution snippet ur looking for,in place of
navigator.language.substr(0,1).toUpperCase() pass ur values dynamically. try with following code
var oCustomerCountry =this.getView().byId("list");
var oSorter= {
path: 'Soldtoparty',
descending: false,
group: true
};
var oFilters = new sap.ui.model.Filter("Salesorganization", sap.ui.model.FilterOperator.EQ, navigator.language.substr(0,1).toUpperCase()); // Dynamic parameter
oCustomerCountry.bindItems("/CustomersListSet", oSorter, oFilters);
Can you please modify the snippet as per my view code. I am trying to use the one from the link, but could nt.
Any suggestions please
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.