-
15 Dec 2011 8:32 AM #1
List selection oddness after underlying store is sorted
List selection oddness after underlying store is sorted
Hi,
I have encountered a very odd issue with a List I have which seems to maintain previous selections after I sort the underlying store.
So for example I select the fourth row in my list, the store then gets sorted which causes the selected row to now be ordered as the first row. I end up with both the first and fourth row selected in my list control.
I then perform another sort, and my selected row now jumps to the fifth position, but I now have rows 1, 4 and 5 selected!
So it seems the list is selecting wherever the record was ordered beforehand.
Am I missing a trick here?
My list view is defined like so:
Code:Ext.define('PinpointersTouch.view.UnitList', { extend: 'Ext.List', xtype: 'unitslist', config: { fullscreen: true, itemTpl: new Ext.XTemplate( '<ul id="unitList">', '<tpl for=".">', '<li>', '<table width="100%" cellspacing="0">', '<tr>', '<td style="width:30px; text-align:center">{MapIconHTML}</td>', '<td valign="middle"> - {UnitName}</td>', '</tr>', '</table>', '<div class="journeyCurrentLocation">{Location}</div>', '<div class="journeyLastReportedTimestamp"><b>Last Reported at:</b> {EventDTLocalDisplay}</div>', '</li>', '</tpl>', '</ul>'), store: 'CurrentGrid' } });
-
15 Dec 2011 9:55 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
I moved this to the bugs forum. I can reproduce using this simple example:
Code:Ext.require([ 'Ext.data.Store', 'Ext.List' ]); Ext.define('Contact', { extend : 'Ext.data.Model', fields: ['firstName', 'lastName'] }); Ext.setup({ onReady : function() { var store = Ext.create('Ext.data.Store', { model: 'Contact', getGroupString : function(record) { return record.get('firstName')[0]; }, data : [ { firstName : 'Mitchell', lastName : 'Simoens' }, { firstName : 'Tommy', lastName : 'Maintz' }, { firstName : 'Ed', lastName : 'Spencer' }, { firstName : 'Jamie', lastName : 'Avins' }, { firstName : 'Aaron', lastName : 'Conran' }, { firstName : 'Dave', lastName : 'Kaneda' }, { firstName : 'Michael', lastName : 'Mullany' }, { firstName : 'Abraham', lastName : 'Elias' }, { firstName : 'Jay', lastName : 'Robinson' } ] }); Ext.create('Ext.dataview.List', { fullscreen : true, store : store, disclosure : true, itemTpl : '<div class="contact2"><strong>{firstName}</strong> {lastName}</div>', listeners : { itemtap : function(list) { var store = list.getStore(); store.sort('firstName'); } } }); } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
6 Jan 2012 3:23 AM #3
Hi Guys,
I see this is still open and wondered if you could suggest a workaround until this gets fixed please?
Thanks
-
9 Jan 2012 1:00 PM #4
To get around this issue for my own application I ended up deselecting the currently selected record prior to any store updates and kept a global reference to the record and then after the store update\sort I just reselected the record.
Code:
Not the most pretty way to do this I know, but it does serve my needs. Are there any better workarounds to this bug that I could use until you guys manage to tackle this issue?Code:\\Before Store Update\Sort this.application.selectedUnitRecord = this.getUnitsPanel().getSelection(); this.getUnitsPanel().deselect(this.application.selectedUnitRecord); \\After Store Update\Sort this.getUnitsPanel().select(this.application.selectedUnitRecord, false,true);
Thanks
-
11 Jan 2012 3:03 PM #5Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,653
- Vote Rating
- 14
This issue has been fixed for the next release.
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1272
in
2.0.


Reply With Quote