Gerrit
Gerrit

Reputation: 2677

How to deselect a selected entry in a List?

in my app I use this code in my xml-view to create a List. Now I can select an entry of the list. I use this entry to filter the values of the detailPage. But how can I deselect an entry, so that nothing is selected?

            <List id="guList" items="{statusData>/SurveySet}" includeItemInSelection="false" mode="SingleSelectMaster" select="filterChange">
                <StandardListItem
                    title='{path: "statusData>text", formatter: ".formatter.emptyText"}'
                    description='{path: "statusData>id", formatter: ".formatter.stringToInt"}'
                    type="Active"/>
            </List>

Thanks

Upvotes: 0

Views: 10914

Answers (1)

Ashish Patil
Ashish Patil

Reputation: 1742

Invoke removeSelections on List object with an argument as true to remove all selections.

this.getView().byId("guList").removeSelections(true);

To remove particular item's selection use setSelectedItem with item to be removed as first argument and it's boolean value as second.

In your case it will be like

this.getView().byId("guList").setSelectedItem(oListItem, false);

Further, you can get currently selected item within selectionChange event handler, which you can preserve and use it to remove selection later on as and when required.

Upvotes: 2

Related Questions