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();就可以了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM