ExtJS,grid多选框列

extjs grid 使用多选框

使用选择框的选择模型是checkboxmodel,代码如下:

xtype: "grid",
store: myStore,
selModel: {
    mode: 'SIMPLE',
    selType: 'checkboxmodel',
    allowDeselect: true,
    bindCheckedField: 'ISCHECKED'
},
columns: [
    { xtype: "rownumberer", text: "行号",  50 },
    { text: "姓名", dataIndex: "Name" },
    { text: "年龄", dataIndex: "Age" }
]

效果如图:

extjs grid 获取选中行

要得到选中行,我们首先要找到grid,然后得到grid的selectionModel,然后再找到选择行,代码如下:

var grid = win.down("grid");
var records = grid.getSelectionModel().getSelection();
Ext.MessageBox.alert("提示", records.length);

自用参考代码(js分离时的写法):

        var me = this,
        records = me.view.selection();
        Ext.MessageBox.alert("提示", records.length);
原文地址:https://www.cnblogs.com/xiaoqi123/p/6687685.html