Ext4.1 grid 多选(可无checkbox)

转载

在Ext4.1中的grid默认只能实现单选的。

如果你想要你的grid有多选功能,需要给grid增加selModel

如果你使用了Ext.create('Ext.selection.CheckboxModel')-->selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"SIMPLE"})

部分代码:

复制代码
 1 this.grid= new Ext.grid.GridPanel({
 2             title : 'users',
 3             store : this.userStore,
 4             columns : [ {
 5                 header : "用户ID",
 6                 sortable : true,
 7                 dataIndex : 'userId'
 8             }, {
 9                 header : "用户名称",
10                 sortable : true,
11                 dataIndex : 'userName'
12             } ],
13             stripeRows : true,
14             manageHeight:true,
15             height:this.height-114,
16             selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"SIMPLE"}),
复制代码

界面效果:

但是这种方式会出现复选框,

如果不想有复选框是需要把selModel换成Ext.create('Ext.selection.RowModel',{mode:"SIMPLE"})就ok了

如图:

 

获得选中的数据用var records = this.grid.getSelectionModel().getSelection();就可以了

posted @ 2014-02-13 10:06  天马3798  阅读(231)  评论(0编辑  收藏  举报