PDA

View Full Version : [SOLVED] Grouped list selecting wrong record



johnholden
3 Jun 2011, 6:15 AM
I just wanted to post this because it took me a some time to figure out.

If you have an Ext.List and you want to group by a particular field, you need to make sure to also set the store sorter on that same group field. If you don't, the result can be a list that appears to be sorted correctly, but when you click an item it actually selects a (potentially) different record.

Broken:


Ext.regStore('Locations', {
model: 'Location',
groupField: 'ipsched',
getGroupString: function(record) {
return record.data.ipsched;
}
});

// ...

this.list = new Ext.List({
itemTpl: '{name}',
store: this.store,
grouped: true
});

Working:

Ext.regStore('Locations', {
model: 'Location',
sorters: [{
property: 'ipsched',
direction: 'ASC'
}],
groupField: 'ipsched',
getGroupString: function(record) {
return record.data.ipsched;
}
});

this.list = new Ext.List({
itemTpl: '{name}',
store: this.store,
grouped: true
});

jep
9 Jun 2011, 7:53 AM
Related:

http://www.sencha.com/forum/showthread.php?135533-OPEN-TOUCH-138-Serious-flaw-with-List-Selection-%28revised%29