var selModel = Ext.create('Ext.selection.CheckboxModel'); Ext.create('Ext.grid.Panel', {
title: '員工建檔',
store: employeeStore,
selModel: selModel,
columnLines: true,
columns: [
Ext.create('Ext.grid.RowNumberer'),
{ header: '員工編號', dataIndex: 'EMPNO', width: 80 },
{ header: '姓名', dataIndex: 'FULLNAME', width: 120 },
{ header: '地址', dataIndex: 'ADDRESS', flex: 1 },
{ header: '年齡', dataIndex: 'AGE', width: 60 },
{ header: '薪水', dataIndex: 'SALARY' },
{ header: 'Email', dataIndex: 'EMAIL', renderer: function (value) { return Ext.String.format('<a href="mailto:{0}">{1}</a>', value, value); } },
{ header: '部門編號', dataIndex: 'DEPTNO', width: 60, renderer: function (value) {
return Ext.String.format('<a href="/HumanResource/Department/{0}">{1}</a>', value, value);
}
}
],
dockedItems: [
{
dock: 'top',
xtype: 'toolbar',
items: [{
itemId: 'Button',
text: '刪除',
tooltip: '刪除用戶資料',
iconCls: 'delete',
handler: function () {
var record = grid.getSelectionModel().getSelection();
if (record.length == 0) {
Ext.MessageBox.show({
title: "提示",
msg: "请先选择您要操作的行!"
//icon: Ext.MessageBox.INFO
})
return;
} else {
var ids = "";
for (var i = 0; i < record.length; i++) {
ids += record[i].get("id")
if (i < record.length - 1) {
ids = ids + ",";
}
}
Ext.MessageBox.show({
title: "所选ID列表",
msg: ids
//icon: Ext.MessageBox.INFO
})
}
}
}]
},
{
dock: 'bottom',
xtype: 'pagingtoolbar',
store: employeeStore,
pageSize: 3,
displayInfo: true,
displayMsg: '顯示 {0} - {1} 條,共計 {2} 條',
emptyMsg: '没有数据'
}], height: 400,
width: 800,
disableSelection: false,
renderTo: 'grid'
});
为什么一直出现 grid.getSelectionModel()没有定义。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货