簡體   English   中英

Ext JS 4:GridPanel-根據更新的單元格更新列單元格值

[英]Ext JS 4 : GridPanel - Update a column cell values based on the updated cell

我有一個顯示文章詳細信息的網格面板。 有幾列。 當我們的員工更改單元格值之一時,我想基於更新的字段匹配所有列字段值。

+----------------------------------------+ 
| 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-1 COL 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  |
+----------------------------------------+

您應該更新后面商店中的記錄。 就像是

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

});

在網格的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);
            });
        }
    }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM