1
votes

I have a grid panel showing article details. There are several columns. When our an employee change the one of cell value, I want to match all column field values based on the updated field.

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

What I want to do, when user change the ROW-1 COL D value (12) with 15, the other rows COL D values should change automatically with 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  |
+----------------------------------------+
2

2 Answers

1
votes

You should update the records in the store behind. Something like

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

});

1
votes

Updates your records in the edit event of the grid.

Here's an example:

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);
            });
        }
    }
});