Looks like we cannot reproduce this. Please provide another test case to reproduce this issue.
  1. #1
    Sencha User jaux's Avatar
    Join Date
    Mar 2012
    Location
    Toronto, ON
    Posts
    5
    Vote Rating
    0
    jaux is on a distinguished road

      0  

    Default [4.1.1] Grid row selection lost upon calling record.set()

    [4.1.1] Grid row selection lost upon calling record.set()


    REQUIRED INFORMATION

    Ext version tested:
    • Ext 4.1.1
    Browser versions tested against:
    • Chrome 22.0
    • Firefox 16.0.1
    • Safari 6.0.1
    Description:

    Select a row in grid panel with single selection mode, update the underlying record by calling record.set() in the select event handler, then the grid row selection will be gone, and click on that row again will not highlight it.

    Steps to reproduce the problem:
    1. Create a grid panel with single selection mode
    2. Listen the select event of the grid panel
    3. In the select event handler, update the record by calling record.set(field, value)
    The result that was expected:

    After updating record, the grid row selection is preserved.

    The result that occurs instead:


    After updating record, the grid row selection is lost.

    Test Case:
    Code:
    Ext.onReady(function() {
        var grid = Ext.create('Ext.grid.Panel', {
            store: {
                fields: ['id', 'value'],
                data: [
                    {id: 1, value: 'initial value'},
                    {id: 2, value: 'initial value'}
                ]
            },
            columns: [
                {text: 'id', dataIndex: 'id'},
                {text: 'value', dataIndex: 'value', flex: 1}           
            ],
            renderTo: Ext.getBody()
        });
    
    
        grid.on('select', function(selModel, record, index) {
            // ExtJS 4.1.1 Bug: select a row, update record, selection will be lost.
            setTimeout(function() {
                record.set('value', Math.random());
            }, 1000);
        });
    });

    HELPFUL INFORMATION

    See this URL for live test case:
    http://jsfiddle.net/jaux/5LFkv/

    Possible fix:

    I've found this issue is because of the incorrect removal of the x-grid-row-selected class of the grid row in Ext.view.Table.onUpdate(), here is my fix:
    Code:
    --- old/Table.js        2012-10-12 03:50:30.000000000 -0400
    +++ new/Table.js        2012-10-12 03:51:09.000000000 -0400
    @@ -700,8 +700,8 @@
                 index,
                 newRow, newAttrs, attLen, i, attName, oldRow, oldRowDom,
                 oldCells, newCells, len, i,
    -            columns, overItemCls,
    -            isHovered, row,
    +            columns,
    +            row,
                 // See if an editing plugin is active.
                 isEditing = me.editingPlugin && me.editingPlugin.editing;
     
    @@ -709,7 +709,6 @@
     
                 index = me.store.indexOf(record);
                 columns = me.headerCt.getGridColumns();
    -            overItemCls = me.overItemCls;
     
                 // If we have columns which may *need* updating (think lockable grid child with all columns either locked or unlocked)
                 // and the changed record is within our view, then update the view
    @@ -718,7 +717,6 @@
                     oldRow = me.all.item(index);
                     if (oldRow) {
                         oldRowDom = oldRow.dom;
    -                    isHovered = oldRow.hasCls(overItemCls);
     
                         // Copy new row attributes across. Use IE-specific method if possible.
                         if (oldRowDom.mergeAttributes) {
    @@ -728,16 +726,12 @@
                             attLen = newAttrs.length;
                             for (i = 0; i < attLen; i++) {
                                 attName = newAttrs[i].name;
    -                            if (attName !== 'id') {
    +                            if (attName !== 'id' && attName !== 'class') {
                                     oldRowDom.setAttribute(attName, newAttrs[i].value);
                                 }
                             }
                         }
     
    -                    if (isHovered) {
    -                        oldRow.addCls(overItemCls);
    -                    }
    -
                         // Replace changed cells in the existing row structure with the new version from the rendered row.
                         oldCells = oldRow.query(me.cellSelector);
                         newCells = Ext.fly(newRow).query(me.cellSelector);
    Additional CSS used:
    • only default ext-all.css
    Operating System:
    • OSX 10.8
    • Fedora 14

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,649
    Vote Rating
    898
    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


    Can reproduce in 4.1.1 but not in 4.1.2 so this has been fixed already.
    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
    Aug 2008
    Location
    Gothenburg
    Posts
    157
    Vote Rating
    2
    Dr. Flink is on a distinguished road

      1  

    Default


    I also experience this issue in 4.1.1. When will 4.1.2 be available for the rest of us none support subscribers?

    Tnx
    Rickard Claeson

Thread Participants: 2

Tags for this Thread