Results 1 to 7 of 7

Thread: [2.0] - Removing a record from store is still returned by DataView's getSelection()

    Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-2802 in a recent build.
  1. #1
    Sencha Premium User
    Join Date
    Mar 2009
    Posts
    254

    Default [2.0] - Removing a record from store is still returned by DataView's getSelection()

    Here's the code to reproduce the issue:

    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
    });
    Click on first 2 items to select them.
    Then execute this code:

    Code:
    var list = Ext.getCmp('ext-list-1'); //Update id if needed
    list.getStore().removeAt(0);
    list.getSelection();
    getSelection() would return 2 records even though the first of them have been removed from the store and DataView's UI too.

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661

    Default

    Thank you for the report.

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661

    Default

    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]);
                }
            }
        }
    });

  4. #4
    Sencha Premium User
    Join Date
    Mar 2009
    Posts
    254

    Default

    Great, thanks for sharing the override Jamie!!

  5. #5
    Sencha Premium User
    Join Date
    Mar 2009
    Posts
    254

    Default

    Quote Originally Posted by Jamie Avins View Post
    This has been fixed for the next release. The following override should resolve this issue:
    Hi Jamie, I just tried the override and it does not work. Still getting the same issue.

  6. #6
    Sencha User
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661

    Default

    Might be due to it being a mixin. The 2.0.1 final will have this in place, most likely will be out today.

  7. #7
    Sencha Premium User
    Join Date
    Mar 2009
    Posts
    254

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •