Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User VDP's Avatar
    Join Date
    Feb 2012
    Location
    Boom, Belgium
    Posts
    85
    Vote Rating
    9
    VDP will become famous soon enough

      0  

    Default Grid loses (visible) selection after store-record edit and after comit

    Grid loses (visible) selection after store-record edit and after comit


    REQUIRED INFORMATION


    Ext version tested:
    • Ext 4.1.1
    Browser versions tested against:
    • Chrome 22
    Description:
    • I have a simple case where I got a grid with an attached store.
      2 buttons. One with a handler that modifies the selected record. One with a handler that commits the selected record.


      When I select a record an push edit -> editing takes place selection (looks lost) if you call
      Code:
      grid.geSelectionModel().getSelection()
      you will see that the record is still selected. It just doesn't show it that way.


      You can't select it again, you first have to select another record, and select the record back.


      Secondly when you select a record click on the commit button, the value is committed, but the selection 'appears' again as lost.
    Steps to reproduce the problem:
    CASE A:
    • select row
    • click the set name button
    CASE B:
    • select other row
    • select edited row again
    • click commit button
    The result that was expected:
    • selection should be kept
    The result that occurs instead:
    • selection lost
    Test Case:


    Code:
    Ext.create('Ext.data.Store', {
        storeId: 'simpsonsStore',
        fields: ['name', 'email', 'phone'],
        data: {
            'items': [{
                'name': 'Lisa',
                "email": "lisa@simpsons.com",
                "phone": "555-111-1224"
            }, {
                'name': 'Bart',
                "email": "bart@simpsons.com",
                "phone": "555-222-1234"
            }, {
                'name': 'Homer',
                "email": "home@simpsons.com",
                "phone": "555-222-1244"
            }, {
                'name': 'Marge',
                "email": "marge@simpsons.com",
                "phone": "555-222-1254"
            }]
        },
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                root: 'items'
            }
        }
    });
    
    
    Ext.create('Ext.container.Container', {
        layout: 'fit',
        renderTo: Ext.getBody(),
        items: [{
            xtype: 'grid',
            store: Ext.data.StoreManager.lookup('simpsonsStore'),
            columns: [{
                text: 'Name',
                dataIndex: 'name'
            }, {
                text: 'Email',
                dataIndex: 'email',
                flex: 1
            }, {
                text: 'Phone',
                dataIndex: 'phone'
            }],
            height: 200,
            buttons: [{
                text: 'commit selection',
                handler: function(){
                    this.up('grid').getSelectionModel().getSelection()[0].commit();
                }
            },{
                text: 'set selection name to maggy',
                handler: function(){
                    this.up('grid').getSelectionModel().getSelection()[0].set('name', 'Maggy');
                }
            }]
        }]
    });‚Äč





    HELPFUL INFORMATION




    Screenshot or Video:
    • attached
    See this URL for live test case: Working fiddle: http://jsfiddle.net/Vandeplas/YZqch/5/


    Temporary dirty fix:Operating System:
    • Win7

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


    Tested on 4.1.1 and selection is lost. Tested on 4.1.2 and selection remains through all steps so looks like this bug was fixed.
    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 VDP's Avatar
    Join Date
    Feb 2012
    Location
    Boom, Belgium
    Posts
    85
    Vote Rating
    9
    VDP will become famous soon enough

      0  

    Default


    How is it solved? What's changed. We only have a licence, no premium support so no access to 4.1.2 (GA). If I knew what was changed I could easily make an override that fixes the issue...

    The issue is in the onUpdate method of the Ext.view.Table class somewhere around this piece of code:

    Code:
    if (oldRowDom.mergeAttributes) {
       oldRowDom.mergeAttributes(newRow, true);
    } else {
        newAttrs = newRow.attributes;
        attLen = newAttrs.length;
        for (i = 0; i < attLen; i++) {
            attName = newAttrs[i].name;
            if (attName !== 'id') {
               oldRowDom.setAttribute(attName, newAttrs[i].value);
            }
        }
    }
    

  4. #4
    Sencha User
    Join Date
    Aug 2008
    Posts
    101
    Vote Rating
    6
    FoxMulder900 is on a distinguished road

      1  

    Default


    Here is my solution to this until 4.1.2 is released.

    I changed the code that VDP posted (from view/Table.js) to the following:
    Code:
                        
    if (oldRowDom.mergeAttributes) {
        var tmpCls = oldRowDom.className;
        oldRowDom.mergeAttributes(newRow, true);
    } else {
        var tmpCls = oldRowDom.getAttribute('class');
        newAttrs = newRow.attributes;
        attLen = newAttrs.length;
        for (i = 0; i < attLen; i++) {
            attName = newAttrs[i].name;
            if (attName !== 'id') {
                oldRowDom.setAttribute(attName, newAttrs[i].value);
            }
        }
    }
    if(tmpCls){
        oldRow.addCls(tmpCls);
    }

Thread Participants: 2

Tags for this Thread