Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1272 in a recent build.
  1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    395
    Vote Rating
    2
    parky128 is on a distinguished road

      0  

    Default 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'        
        }
    	
    
    
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,643
    Vote Rating
    816
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jun 2009
    Posts
    395
    Vote Rating
    2
    parky128 is on a distinguished road

      0  

    Default


    Hi Guys,

    I see this is still open and wondered if you could suggest a workaround until this gets fixed please?

    Thanks

  4. #4
    Sencha User
    Join Date
    Jun 2009
    Posts
    395
    Vote Rating
    2
    parky128 is on a distinguished road

      0  

    Default


    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:

    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);
    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?

    Thanks

  5. #5
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    21
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    This issue has been fixed for the next release.

    Sencha Inc

    Jamie Avins

    @jamieavins

Thread Participants: 2