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