简体   繁体   中英

Sencha Touch Picker show() with last selection

If I selected a data in Sencha Touch Picker component and hide it, after I show the picker, the selection is only the first record every time.

I would like to show the picker with my last selection is picked.

I tried,

var selection = slot.getSelection();
picker.hide();

slot.select(selection);
picker.show();

in this case, the selection of slot is last selection that I wanted. However, the picker always showed with the first record is picked. Maybe it has been default value.

How to show picker with my last selection is picked ?

As per the document, you can use slot's select method as follows:

select( records, keepExisting, suppressEvent )

Here keepExisting is boolean and if it is true, the existing selection will be added to new record and if not, the old selection will get replaced. So here, in your case old selection may get replaced. Hence using below code will help you to resolve the issue:

var selection = slot.getSelection();
picker.hide();

slot.select(selection, true, true); //you can modify this as per your need
picker.show();

Please read below note before using a slot :

NOTE: This is a private utility class for internal use by the framework. Don't rely on its existence.

Hope it will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM