on 09-23-2016 12:34 PM
Hi,
I am using sap.ui.comp.filterbar.FilterBar control . I am trying bind aggragtions "filterItems" as below.
<fb:FilterBar reset="onReset" search="onSearch" showRestoreButton="true" showClearButton="true" filterBarExpanded="false"
filterItems="{/Filters}">
<fb:filterItems>
<fb:FilterItem name="{Name}" label="{Label}">
<fb:control>
<Input valueHelpRequest="handleValueHelp" showValueHelp="true" valueHelpOnly="true"/>
</fb:control>
</fb:FilterItem>
</fb:filterItems>
</fb:FilterBar>
and my data looks like:
{
"Filters":[
{"Name":"A", "Label":"LabelA"},
{"Name":"B", "Label":"LabelA"},
{"Name":"C", "Label":"LabelA"},
{"Name":"D", "Label":"LabelA"}
]
}
It throws an error in library "filterBar.js",
FilterBar.js:6 Uncaught (in promise) Error: sap.ui.comp.filterbar.FilterBar.prototype.addFilterItem() Expected argument 'oFilterItem.name' may not be null nor empty(…)
I have checked the binding context of filter item in addFilterItem method in filterBar.js, I can see teh proper binding context there.
I tried to bind in script, but no luck.
Is there an issue with aggregation binding of Filter Bar?
Thanks in advance.
Hello Anjani,
What are you trying to accomplish? I guess you want to define your filters dynamically. I'd advice you to try to define them statically, if it works then you can always enhance it at runtime with code.
What I'm saying is, remove the filterItems attribute from your FilterBar tag. Inside the filterItems aggregation define as many filterItems as you want, with a fixed name and a fixed label.
<fb:FilterBar reset="onReset" search="onSearch" showRestoreButton="true" showClearButton="true" filterBarExpanded="false"
name="MyFilter">
<fb:filterItems>
<fb:FilterItem name="Filter1" label="Label 1">
<fb:control>
<Input valueHelpRequest="handleValueHelp" showValueHelp="true" valueHelpOnly="true"/>
</fb:control>
</fb:FilterItem>
</fb:filterItems>
</fb:FilterBar>
In your controller you can alter your controls with something like this:
var oFilterBar = this.byId("MyFilter").
for ( var i = 0; i < Filters; i++ ) {
oFilterBar.addFilterItem(
new sap.ui.comp.FilterItem({
name: Filters[i].Name,
label: Filters[i].Label
});
)
}
Regards,
Leonardo.
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.