Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    18
    Vote Rating
    0
    cellinger is on a distinguished road

      0  

    Default [4.1 RC1] Cannot select records from store-backed grid with custom store.data.getKey

    [4.1 RC1] Cannot select records from store-backed grid with custom store.data.getKey


    REQUIRED INFORMATION
    Ext version tested:
    • Ext 4.0.7
    • Ext 4.1 RC1
    Browser versions tested against:
    • IE9
    • FF10 (firebug 1.9.1 installed)
    • Chrome 17
    DOCTYPE tested against:
    DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"


    Description:
    • If you override the getKey method of the Ext.util.MixedCollection data object within an Ext.data.Store, the grid view is no longer able to link records selected in the view to records in the Store. The issue stems from Ext.view.AbstractView. In the updateIndexes private method, a custom attribute called viewRecordId is set to the record's internalId property:
    Code:
    updateIndexes : function(startIndex, endIndex) {
        var ns = this.all.elements,
            records = this.store.getRange(),
            i;
       startIndex = startIndex || 0;
        endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
        for(i = startIndex; i <= endIndex; i++){
            ns[i].viewIndex = i;
            ns[i].viewRecordId = records[i].internalId;
            if (!ns[i].boundView) {
                ns[i].boundView = this.id;
            }
        }
    }
    
    Later, when a row on the grid is selected, the getRecord() method is called:
    Code:
    getRecord: function(node){
        return this.store.data.getByKey(Ext.getDom(node).viewRecordId);
    }
    
    This fails because the viewRecordId does not match the key used for the data collection's hash map.

    Steps to reproduce the problem:
    • Create a store object and override the getKey method on the store's data collection.
    • Load data into the store
    • Create a grid backed by the store
    • Attempt to select a row on the grid
    The result that was expected:
    • Record should be selected without error.
    The result that occurs instead:
    • A JavaScript error occurs because the record is undefined
    Test Case:
    See http://jsfiddle.net/3ZyXN/9/ for an example.

    HELPFUL INFORMATION
    Screenshot or Video:
    • N/A
    Debugging already done:
    • none
    Possible fix:
    • not provided
    Additional CSS used:
    • only default ext-all.css
    Operating System:
    • Windows 7 Professional

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,170
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    This isn't really a bug. In this instance you're messing around with the internals of the class. Obviously this is "allowed", however by the same token you need to account for such things in your own code. The store itself explicitly passes a getKey function already, which you're overriding.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    18
    Vote Rating
    0
    cellinger is on a distinguished road

      0  

    Default


    Thanks for the reply. The functionality was working in Ext 2.2, but you're right, it's an edge case where we are messing with class internals. I'll find a suitable workaround.

Thread Participants: 1