在存储记录编辑之后和提交之后网格丢失(可见)选择

VDP*_*VDP 4 javascript extjs

我有一个简单的案例,我有一个连接商店的网格.

有2个按钮.一个带有修改所选记录的处理程序.一个具有提交所选记录的处理程序.

当我选择一个记录并按下编辑 - >编辑发生选择(看起来丢失)如果你打电话,grid.geSelectionModel().getSelection()你会看到记录仍然被选中.它只是没有这样显示.

您无法再次选择它,首先必须选择另一条记录,然后选择记录.

其次,当您选择一个记录时,单击提交按钮,该值将被提交,但选择"再次显示"为丢失.

这是一个错误吗?我怎样才能解决这个问题?我想让它保持选择可见!

这是一个小提琴

这是示例代码:(我使用Ext 4.1.1)

var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
        clicksToEdit: 1
    });

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');
            }
        }]
    }]
});?
Run Code Online (Sandbox Code Playgroud)

更新:

我在sencha论坛上报告过.Mitchel Simoens告诉我它已在Ext 4.1.2中修复.太糟糕了,这是一个'仅支持订阅者'版本..

更新:

我正在找到问题来尝试修复它.我相信这个问题位于onUpdate方法的Ext.view.Table类中,更精确地围绕这段代码:

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);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

将这段代码留下来是不是一个坏主意?我评论它似乎现在正在工作,但它不会破坏其他功能吗?http://jsfiddle.net/Vandeplas/YZqch/10/

bld*_*ron 6

我认为这是一个错误,可能是刷新网格以显示脏位的一部分.在你修改过的小提琴中
,我以一种丑陋的方式规避了这一点:

{
    text: 'set selection name to maggy',
    handler: function(){
        var sel = this.up('grid').getSelectionModel();
        var rec = sel.getSelection()[0];
        rec.set('name', 'Maggy');
        sel.deselectAll();
        sel.select(rec.index);
    }
}
Run Code Online (Sandbox Code Playgroud)

我这样做了.set(),但同样可以做到commit()

希望这有点帮助.