如何读取和设置ExtJS网格中特定单元格的值?

Lou*_*Lou 11 grid extjs

我是从ExtJS开始的.我正在尝试从选中的单元格中读取一个值,
我使用的是EditorGrid,并且该商店看起来像这样:

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

截至目前,这是我用来检索所选单元格的行和列的内容:

var column = grid.getSelectionModel().selection.cell[0];
var row    = grid.getSelectionModel().selection.cell[1];
Run Code Online (Sandbox Code Playgroud)

如何读取网格中所选单元格的值并更改此值?

Llo*_*oyd 12

这完全取决于您的选择模型.使用a RowSelectionModel可以获得所选行的记录,如下所示:

var sel_model = grid.getSelectionModel();
var record = sel_model.getSelection()[0];
Run Code Online (Sandbox Code Playgroud)

然后你需要做的就是使用set()方法:

record.set("c_1","Test");
Run Code Online (Sandbox Code Playgroud)

当然,EditorGridPanel你应该将编辑分配给控件而不是直接分配.