//Update: I use this <select>
control in Filter Bar
In control of UI5,if I select one item, I can't go back to non-selected state, so I want to add 'All' value in items:
This works:
<Select>
<core:Item key="" text="All" />
<core:Item key="another value" text="another value"/>
</Select>
But "All" disapear in this example:
<Select
items="{
path: '/PRODUCTS'
}">
<core:Item key="" text="All" />
<core:Item key="{ID}" text="{Route_Name}" />
</Select>
What should I do?
You must add some key value to the item with text="All". Please have a look in the jsbin working example.
add below where you set Model.
Similar to @vivek' answer, append an All when data loaded:
If you want to let users to select none item again, I'd recommend to use sap.m.ActionSelect or sap.m.ComboBox over a basic Select control.
In case of ActionSelect: Turn off forcing selection with
forceSelection:false
and add an action button with a press event handler executingmyActionSelect.close().setSelectedKey("");
. Here is an example: https://embed.plnkr.co/tk9ulw/I did this by creating two arrays, one with the 'All' key/value pair, then another with my list of items, then concat() them together. In your JSON view model, declare the array:
selections[];
In the onBeforeRendering() lifecycle method, check if the array is populated (< 0), and if so, read the entity set which contains your list:
Upon success, build the array and set the property:
A FacetFilter control would suit your requirement. It has an all selection to select all the values in the List.