on 02-04-2017 10:41 AM
Hi all,
I have a list and I need to load the list dynamically based on the filter value passed to it. I use XML view for coding. Here's is what I have tried.
View.xml:
<List id="Aprovalmat" items="{path: '/TRANS_MATSet',
filters : [
{path : 'Pa',operator : 'EQ',value1:'ALG1'},
{path : 'PfNum',operator : 'EQ',value1:'4045'},
{path : 'Psa',operator : 'EQ',value1:'AL01'} ] }">
<items>
<StandardListItem id="idtrmatrix" title="{Name}" info="{Designation}" />
</items> </List>
This works fine when the 'value1' field is static. But now, I need to pass dynamic values to the 'value1' field. I changed my code to the following:
View.xml:
<List id="Aprovalmat"></List>
Controller.js:
var list = sap.ui.getCore().byId("Aprovalmat");
var oItems = new sap.m.ObjectListItem({ title: "{Name}", number:"{Designation}", numberUnit:"", type:"Active" });
var oFilters = [ new sap.ui.model.Filter("Pa", sap.ui.model.FilterOperator.EQ, pacode),
new sap.ui.model.Filter("PfNum", sap.ui.model.FilterOperator.EQ, pfcode),
new sap.ui.model.Filter("Psa", sap.ui.model.FilterOperator.EQ, psacode)]; list.bindItems("/TRANS_MATSet",oItems,oFilters);
I face an issue binding the data to the list and I was not able to achieve it.
Can Someone help me with this?
Thanks & Regards,
Ramya
you have to do it in the controller, not able to do it in xml binding
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
var list = sap.ui.getCore().byId("Aprovalmat");
change to
var list = this.byId("Aprovalmat");
Hi Ramya,
Can you try something like below:
var list = sap.ui.getCore().byId("Aprovalmat");
var oItems = new sap.m.ObjectListItem({
title: "{Name}",
number: "{Designation}",
numberUnit: "",
type: "Active"
});
var oFilters = [new sap.ui.model.Filter("Pa", sap.ui.model.FilterOperator.EQ, pacode),
new sap.ui.model.Filter("PfNum", sap.ui.model.FilterOperator.EQ, pfcode),
new sap.ui.model.Filter("Psa", sap.ui.model.FilterOperator.EQ, psacode)
];
list.bindAggregation("items", {
path: '/TRANS_MATSet',
template: oItems,
filters: oFilters
});
Regards,
Sai.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
3rd argument in list.bidnItems() is sorters. Can you please try this way?
list.bindItems("/TRANS_MATSet",oItems, null, oFilters);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
9 | |
9 | |
9 | |
6 | |
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.