-
19 Apr 2012 10:16 AM #1
[2.0] - Removing a record from store is still returned by DataView's getSelection()
[2.0] - Removing a record from store is still returned by DataView's getSelection()
Here's the code to reproduce the issue:
Click on first 2 items to select them.Code:Ext.define('Contact', { extend: 'Ext.data.Model', config: { fields: ['firstName', 'lastName'] } }); var store = Ext.create('Ext.data.Store', { model: 'Contact', sorters: 'lastName', data: [ { firstName: 'Tommy', lastName: 'Maintz' }, { firstName: 'Rob', lastName: 'Dougan' }, { firstName: 'Ed', lastName: 'Spencer' }, { firstName: 'Jamie', lastName: 'Avins' }, { firstName: 'Aaron', lastName: 'Conran' }, { firstName: 'Dave', lastName: 'Kaneda' }, { firstName: 'Jacky', lastName: 'Nguyen' }, { firstName: 'Abraham', lastName: 'Elias' }, { firstName: 'Jay', lastName: 'Robinson'}, { firstName: 'Nigel', lastName: 'White' }, { firstName: 'Don', lastName: 'Griffin' }, { firstName: 'Nico', lastName: 'Ferrero' }, { firstName: 'Nicolas', lastName: 'Belmonte'}, { firstName: 'Jason', lastName: 'Johnston'} ] }); Ext.create('Ext.List', { fullscreen: true, itemTpl: '<div class="contact">{firstName} <strong>{lastName}</strong></div>', mode: 'MULTI', store: store });
Then execute this code:
getSelection() would return 2 records even though the first of them have been removed from the store and DataView's UI too.Code:var list = Ext.getCmp('ext-list-1'); //Update id if needed list.getStore().removeAt(0); list.getSelection();
--
Rahul Singla
-
19 Apr 2012 10:27 AM #2Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,651
- Vote Rating
- 14
Thank you for the report.
-
19 Apr 2012 10:38 AM #3Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,651
- Vote Rating
- 14
This has been fixed for the next release. The following override should resolve this issue:
Code:Ext.define('Override.selectable', { override: 'Ext.dataview.DataView', onSelectionStoreRemove: function(store, records) { var me = this, selected = me.selected, ln = records.length, record, i; if (me.getDisableSelection()) { return; } for (i = 0; i < ln; i++) { record = records[i]; if (selected.remove(record)) { if (me.getLastSelected() == record) { me.setLastSelected(null); } if (me.getLastFocused() == record) { me.setLastFocused(null); } me.fireSelectionChange([record]); } } } });
-
19 Apr 2012 11:35 PM #4
Great, thanks for sharing the override Jamie!!
--
Rahul Singla
-
21 Apr 2012 9:48 AM #5
--
Rahul Singla
-
23 Apr 2012 8:50 AM #6Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,651
- Vote Rating
- 14
Might be due to it being a mixin. The 2.0.1 final will have this in place, most likely will be out today.
-
11 Jun 2012 4:36 AM #7
Hi Jamie, this still seems to be an issue in 2.0.1.1
The same sample code as in the opening post reproduces it. Let me know if I should create a new thread as this has been marked fixed.--
Rahul Singla
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-2802
in
Sprint 21 (2.0.1).


Reply With Quote