如何读取和设置 ExtJS 网格中特定单元格的值? [英] How to read and set a value of a specific cell in an ExtJS Grid?

查看:29
本文介绍了如何读取和设置 ExtJS 网格中特定单元格的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 ExtJS 开始.我正在尝试从选定的单元格中读取值
我使用 EditorGrid 和看起来像这样的商店:

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 ?

推荐答案

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

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.getSelection()[0];

那么你需要做的就是使用 set() 方法:

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

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

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

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

这篇关于如何读取和设置 ExtJS 网格中特定单元格的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆