View Full Version : [INFOREQ] Programmatic List selection change fails until list is shown

30 Mar 2011, 9:00 AM

Using Touch 1.1.0.

I tried to initialize List selected item before and after list's initComponent(), but it fails until the list was displayed at least once. So, expected behavior: selection should work after data is supplied to the list even if the list has not been shown before. After the list was displayed for the first time, selection works alright. FYI, in this particular case the list was on a floating panel. (I tried to work around the problem by trying to do initial list selection not until its parent panel 'activate' event was risen, but it appears that another bug got in the way: activate event does not seem to be fired for a floating panel.)

Here's the code:

function SelectListItem(list, itemIndex) {

//try {
if (itemIndex >= list.store.data.length)

var selModel = list.getSelectionModel();
selModel.select(itemIndex); // <<<<<<<< FAILS HERE
// }
// catch (ex) {
// console.log(ex);
// }

Here's the exception stack:

1. Uncaught TypeError: Cannot call method 'addCls' of null
1. Ext.DataView.Ext.extend.onItemSelect sencha-touch-debug.js:22967
2. Ext.DataViewSelectionModel.Ext.extend.onSelectChange sencha-touch-debug.js:22477
3. Ext.AbstractStoreSelectionModel.Ext.extend.doMultiSelect sencha-touch-debug.js:22206
4. Ext.AbstractStoreSelectionModel.Ext.extend.doSelect sencha-touch-debug.js:22176
5. Ext.AbstractStoreSelectionModel.Ext.extend.select sencha-touch-debug.js:22157
6. SelectListItem TouchMain.js:248
7. Views.WorkOrderDetailView.Ext.extend.onActivatedWorkOrderDetailView.js:131
8. firesencha-touch-debug.js:979
9. Ext.util.Observable.Ext.extend.fireEventsencha-touch-debug.js:595
10. Ext.Anim.run.aftersencha-touch-debug.js:29733
11. Ext.Anim.Ext.extend.onTransitionEndsencha-touch-debug.js:13426
12. anonymous:5
13. (anonymous function)sencha-touch-debug.js:4428

Thank you,

5 Sep 2011, 9:11 PM
I ran into this same issue. Is this another thread that slipped through the cracks recently?

7 Sep 2011, 9:57 AM
try this override that makes onItemSelect a little more cautious:

Ext.override(Ext.DataView, {
onItemSelect: function(record) {
var node = this.getNode(record);
var node_el = Ext.get(node)
if (node_el) {

this seems to work in my tests, can you confirm?

17 Sep 2011, 10:09 PM
I have the same problem. Tried Mike's solution - didn't work (no TypeError after calling select but whole selection went nuts - first row selected even when tapping on others). Any thoughts?

24 Feb 2012, 7:15 AM
I select records in data grid (TouchGridPanel plugin) and that workaround works fine!
Yet another workaround to my collection. I wonder how I will migrate to ST2 with all thouse workarounds and bux fixes....

btw, you should also fix "onItemDeselect" in the same way to avoid errors.

onItemDeselect: function(record) {
var node = this.getNode(record);
var node_el = Ext.get(node)
if (node_el) {