Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Selection disappears when scolling in an infinite grid

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-7013 in a recent build.
  1. #11
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    20
    Vote Rating
    0
      0  

    Default

    Hi Animal,

    thanks for the fix.

    While the selection now visually remains, when you add an event listener:

    grid.getSelectionModel().on("selectionchange",function(aSelectionModel,aSelectedEntries){

    It still gets called with aSelectedEntries=[] when scrolling down, while the selection remains visible in the grid when srolling up again.

  2. #12
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,615
    Vote Rating
    55
      0  

    Default

    The patch is not perfect. The thing is, the record does get unselected when it gets scrolled out of the store, and reselected when it re-enters the store.

    The selection classes do not play well with the concept of persistently selected records which cycle back in as a different instance later.

    It will need fixing. Hopefully the patch above will work for now while this bug is addressed.

  3. #13
    Sencha User
    Join Date
    Feb 2008
    Posts
    63
    Vote Rating
    3
      0  

    Default

    I've fixed this issue by extending RowModel.

    Code:
            Ext.define('Ext.ux.es.RowModelWithMemory', {
                extend: 'Ext.selection.RowModel',
                alias: 'selection.rowmodelwithmemory',
                
                selected_row_ids: new Ext.util.HashMap(),
    
                constructor: function() {
                    Ext.ux.es.RowModelWithMemory.superclass.constructor.apply(this, arguments);
                    this.on('select', function(me, record, rowIdx){
                        me.selected_row_ids.add(record.getId(), true);
                        return true;
                    });
                    this.on('deselect', function(me, record, rowIdx){
                        me.selected_row_ids.removeAtKey(record.getId(), true);
                        return true;
                    });
                },
                
                refresh: function() {
                    var me = this;
                     Ext.ux.es.RowModelWithMemory.superclass.refresh.call(me);
                     var keys = me.selected_row_ids.getKeys();
                     var store = me.store;
                     var toBeSelected = [];
                     for(var i = 0;i<keys.length;i++) {
                         var record = store.getById(me.selected_row_ids.get(keys[i]));
                         if (record && !me.isSelected(record)) {
                             toBeSelected.push(record);
                         }
                     }
                    if (toBeSelected.length) {
                        // perform the selection again
                        me.doSelect(toBeSelected, false, true);
                    }
                }
            });

  4. #14
    Ext JS Premium Member
    Join Date
    Mar 2009
    Posts
    201
    Vote Rating
    2
      0  

    Default

    urban novak - nice solution! When you select items, scroll away, and then scroll back the selected items hold nicely.

    Unfortunately this solution does not cover all cases yet. There are errors when shift selecting items across page loads.

    how to reproduce:
    -select 1 item
    -scroll away
    -shift select to select all items

    We end up trying to add an undefined record when multiSelecting resulting in a "TypeError: o is undefined" error. I think this portion of the problem will not be trivial (but you are welcome to prove me wrong).

  5. #15
    Sencha User
    Join Date
    Oct 2009
    Posts
    14
    Vote Rating
    0
      0  

    Default

    I see that this has been fixed in EXTJSIV-7013 - Selection disappears when scrolling in an infinite grid in Ext 4.2.1. Is there a workaround for it in an old version 3.2.1?

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

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