1

我有一个显示文章详细信息的网格面板。有几列。当我们的员工更改单元格值之一时,我想根据更新的字段匹配所有列字段值。

+----------------------------------------+ 
| ROW ID | COL A | COL B | COL C | COL D | 
+----------------------------------------+ 
|   1    |   TR  |  IST  |  100  |   12  |
+----------------------------------------+
|   2    |   US  |   NY  |   60  |    7  |
+----------------------------------------+
|   3    |   DE  |  BER  |   74  |    9  |
+----------------------------------------+

我想要做的是,当用户将 ROW-1COL D值 (12) 更改为 15 时,其他行COL D值应自动更改为15.

+----------------------------------------+ 
| ROW ID | COL A | COL B | COL C | COL D | 
+----------------------------------------+ 
|   1    |   TR  |  IST  |  100  |   15  | <- user has changed the value
+----------------------------------------+
|   2    |   US  |   NY  |   60  |   15  |
+----------------------------------------+
|   3    |   DE  |  BER  |   74  |   15  |
+----------------------------------------+
4

2 回答 2

1

您应该更新存储在后面的记录。就像是

store.each(function(record){
    record.set('col_d', 15);

});

于 2013-06-03T11:17:59.457 回答
1

edit在网格事件中更新您的记录。

这是一个例子:

Ext.widget('grid', {
    renderTo: Ext.getBody()
    ,columns: [{dataIndex: 'a', header: 'Col A', editor: 'textfield'}]
    ,store: {
        fields: ['a']
        ,data: [{a: 1},{a:2},{a:3}]
    }
    ,plugins: [
        Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 1
        })
    ]
    ,listeners: {
        // this event is added to the grid by the CellEditing plugin
        edit: function(editor, e) {
            e.grid.getStore().each(function(record) {
                record.set('a', e.value);
            });
        }
    }
});
于 2013-06-03T11:31:52.037 回答