Search code examples
sapui5

What's the best way to add add 'All' value to <Select> Control?


//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?


Solution

  • A FacetFilter control would suit your requirement. It has an all selection to select all the values in the List.

    <FacetFilter
                id="idFacetFilter"
                type="Simple"
                confirm="handleConfirm">
                <lists>
                    <FacetFilterList
                        title="Route"
                        key="route"
                        mode="MultiSelect"
                        items="{
                            path: '/PRODUCTS'
                        }" >
                        <items>
                            <FacetFilterItem
                                text="{Route_Name}"
                                key="{ID}" />
                        </items>
                    </FacetFilterList>
                </lists>
            </FacetFilter>