tags:

views:

772

answers:

1

Hello, I am beginning with ExtJS. I am trying to read a value from a cell that is selected
I use an EditorGrid and the store looking like that :

my_store = new Ext.data.JsonStore({
    root: 'topics',
    totalProperty: 'totalCount',
    idProperty: 'details_id',

    fields: [
        {name : 'index',    type : 'int'},
        {name : 'inactive', type : 'int'},
        {name : 'c_1',      type : 'string'},
        {name : 'c_2',      type : 'string'},
        {name : 'c_3',      type : 'string'},
        {name : 'c_4',      type : 'string'}
    ],
    proxy: new Ext.data.ScriptTagProxy({
        url: 'my_proxy_url'
    })
});

As of now, this is what I use to retrieve the rows and columns of the selected cell :

var column = grid.getSelectionModel().selection.cell[0];
var row    = grid.getSelectionModel().selection.cell[1];

How can I read the value of a selected cell in the grid and change this value ?

+2  A: 

It entirely depends upon your selection model. With a RowSelectionModel you can get the Record of the selected row like thus:

var sel_model = grid.getSelectionModel();
var record = sel_model.getSelected();

Then all you need do is use the set() method:

record.set("c_1","Test");

Of course, with an EditorGridPanel you're supposed to assign editing to controls and not directly.

Lloyd