如何在ExtJS网格中读取和设置特定单元格的值?
我从ExtJS开始。我正在尝试从选定的单元格中读取值如何在ExtJS网格中读取和设置特定单元格的值?,extjs,grid,Extjs,Grid,我从ExtJS开始。我正在尝试从选定的单元格中读取值 我使用EditorGrid,商店看起来是这样的: my_store = new Ext.data.JsonStore({ root: 'topics', totalProperty: 'totalCount', idProperty: 'details_id', fields: [ {name : 'index', type : 'int'}, {name : 'inac
我使用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'
})
});
现在,我使用以下内容检索所选单元格的行和列:
var column = grid.getSelectionModel().selection.cell[0];
var row = grid.getSelectionModel().selection.cell[1];
如何读取网格中选定单元格的值并更改此值?这完全取决于您的选择模型。使用
RowSelectionModel
可以获得所选行的记录,如下所示:
var sel_model = grid.getSelectionModel();
var record = sel_model.getSelection()[0];
var sel_model = grid.getSelectionModel();
var record = sel_model.getSelection()[0];
然后,只需使用set()方法:
当然,使用
EditorGridPanel
您应该将编辑分配给控件,而不是直接分配给控件。这里已经很好地解释了这一点
@Llyod
根据你的回答,
这完全取决于您的选择模式。使用
RowSelectionModel
可以获得所选行的记录,如下所示:
var sel_model = grid.getSelectionModel();
var record = sel_model.getSelection()[0];
var sel_model = grid.getSelectionModel();
var record = sel_model.getSelection()[0];
然后,您只需使用set()
方法:
record.set("c_1","Test");
当然,使用EditorGridPanel,您应该将编辑分配给控件,而不是直接分配给控件
这是可行的,但如果我想通过使用列value(例如4或5)
而不是列名来访问单元格的值,该怎么办。
也可以这样做吗谢谢……非常感谢……这就是我正在搜索的内容。祝福你