Ext JS 4.1 -如何访问网格中的cell元素



我有一个带复选框的网格。默认情况下,将根据数据库中的数据选择一些复选框。我使用renderer方法来创建HTML复选框。

现在用户可以选择新的复选框并将该数据提交给服务器。要提交此数据,我如何知道某个特定的复选框是否被选中?我的意思是如何获得特定的单元格元素。

更新:

这是我用来添加复选框的代码

renderer: function (value, cell) {
                            if(value == 'Y')
                                return '<input type="checkbox" name="mycheckbox" checked="true"/>';
                            else
                                return '<input type="checkbox" name="mycheckbox"/>';
                        }

现在我需要检查所有的复选框是否被选中。

我已经尝试使用下面的代码,但这是给复选框的值,而不是它选中或不选中。

store.getAt(1).get(dataIndex);

谢谢拉维

不呈现自己的复选框,只使用Check列,它将在选中时更新底层字段。

见https://fiddle.sencha.com/小提琴/7 n0

var store = Ext.create('Ext.data.Store', {
    fields : ['name', 'email', 'phone', 'active'],
    data   : {
        items : [
            { name : 'Lisa',  email : 'lisa@simpsons.com',  phone : '555-111-1224', active : true  },
            { name : 'Bart',  email : 'bart@simpsons.com',  phone : '555-222-1234', active : true  },
            { name : 'Homer', email : 'home@simpsons.com',  phone : '555-222-1244', active : false },
            { name : 'Marge', email : 'marge@simpsons.com', phone : '555-222-1254', active : true  }
        ]
    },
    proxy  : {
        type   : 'memory',
        reader : {
            type : 'json',
            root : 'items'
        }
    }
});
Ext.create('Ext.grid.Panel', {
    title    : 'Simpsons',
    height   : 200,
    width    : 400,
    renderTo : Ext.getBody(),
    store    : store,
    columns  : [
        { text : 'Name', dataIndex : 'name' },
        { text : 'Email', dataIndex : 'email', flex : 1 },
        { text : 'Phone', dataIndex : 'phone' },
        { xtype : 'checkcolumn', text : 'Active', dataIndex : 'active' }
    ]
});

// Show the modified records
 var recs = store.getRange();
 var data = recs.map(function(o){return o.data;});
 alert(Ext.encode(data));

最新更新