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

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

问题描述

我开始用ExtJS。我试图从选定的单元格中读取一个值

我使用EditorGrid,并且这样看起来像:

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

字段:
{name:'index',type:'int'},
{name:'inactive',type:'int'},
{name: c_1',键入:'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'
})
});

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

  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];

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

  record.set(c_1,Test); 

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


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 ?

解决方案

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];

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.

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

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