http://my.oschina.net/u/1398304/blog/289227
grid.getSelectionModel()的所有操作
1. var model = grid.getSelectionModel();
2. model.selectAll();//选择所有行
3. model.selectFirstRow();//选择第一行
4. model.selectLastRow([flag]);//选择最后一行,flag为正的话保持当前已经选中的行数,不填则默认false
5. model.selectNext();//选择下一行
6. model.selectPrevious();//选择上一行
7. model.selectRange(tartRow,ndRow, [Boolean keepExisting] );//选择范围间的行
8. model.selectRow(row);//选择某一行
9. model.selectRows(rows);//选择指定一些行,传递数组如[1,3,5],则分别选择1,3,5行
10. model.clearSelections();//清空所有选择
11. model.deselectRange( startRow, endRow );//取消从startrow到endrow的记录的选择状态
12. model.deselectRow(row);//取消指定行的记录
- var data = {users:[
- {mid:'1',mname:'非诚勿扰'},
- {mid:'2',mname:'让子弹飞'},
- {mid:'3',mname:'锦衣卫'},
- {mid:'4',mname:'狄仁杰4'}
- ]}
- var store = new Ext.data.Store({
- fields:['mname','mid'],
- data : data,
- proxy: {
- type: 'memory',
- reader: {
- type: 'json',
- root: 'users'
- }
- }
- });
- //combox弹出
- var grid = new Ext.grid.GridPanel({
- width:100,
- height: 200,
- store: store,
- viewConfig:{
- forceFit:true
- },
- columns:[{header:'姓名',dataIndex:'mname',width: 90}
- ],
- selType:'checkboxmodel',//设定选择模式
- multiSelect:true,//运行多选
- dockedItems: [{
- xtype: 'toolbar',
- dock: 'bottom',
- items: [
- {xtype: 'button', text: '确定',handler:function(){
- var m = grid.getSelectionModel().getSelection();
- var ids = [];
- for(var i=0;i
- ids.push(m.get('id'));
- }grid.hide()}},
- {xtype: 'button', text: '取消',handler:function(){
- grid.hide();
- }}
- ]
- }]
- });
- var showMenu = new Ext.menu.Menu({
- items : [grid]
- });
- panel = Ext.create('Ext.form.Panel', {
- title: '按条件搜索', width: 600, height:100, defaultType:'textfield', frame: true, method:'POST', collapsible: true,//可折叠bodyPadding: 5, layout: 'column', margin: '0 0 0 0', items: [{ fieldLabel: '姓名', margin: '0 0 20 20', labelWidth: 40, labelAlign:'right', id: 'name' },{ xtype: 'combo', labelWidth: 40, fieldLabel: '测试', store:new Ext.data.ArrayStore({ fields: ['mid','mname'], data:[[]] }), id: "combo1", queryMode: 'local', valueField: 'mid', displayField: 'mname', listeners:{ expand:function(combo){ if(this.menu == null) { this.menu = showMenu; store.load(); }else{ grid.show(); } this.menu.showBy(this.el ); } } }); }
- }]
var data = {users:[
{mid:'1',mname:'非诚勿扰'},
{mid:'2',mname:'让子弹飞'},
{mid:'3',mname:'锦衣卫'},
{mid:'4',mname:'狄仁杰4'}
]}
var store = new Ext.data.Store({
fields:['mname','mid'],
data : data,
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'users'
}
}
});
//combox弹出
var grid = new Ext.grid.GridPanel({
width:100,
height: 200,
store: store,
viewConfig:{
forceFit:true
},
columns:[{header:'姓名',dataIndex:'mname',width: 90}
],
selType:'checkboxmodel',//设定选择模式
multiSelect:true,//运行多选
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
items: [
{xtype: 'button', text: '确定',handler:function(){
var m = grid.getSelectionModel().getSelection();
var ids = [];
for(var i=0;i.get('id'));
}grid.hide()}},
{xtype: 'button', text: '取消',handler:function(){
grid.hide();
}}
]
}]
});
var showMenu = new Ext.menu.Menu({
items : [grid]
});
panel = Ext.create('Ext.form.Panel', {
title: '按条件搜索', width: 600, height:100, defaultType: 'textfield', frame: true, method: 'POST', collapsible: true,//可折叠bodyPadding: 5, layout: 'column', margin: '0 0 0 0', items: [{ fieldLabel: '姓名', margin: '0 0 20 20', labelWidth: 40, labelAlign:'right', id: 'name' },{ xtype: 'combo', labelWidth: 40, fieldLabel: '测试', store:new Ext.data.ArrayStore({ fields: ['mid','mname'], data:[[]] }), id: "combo1", queryMode: 'local', valueField: 'mid', displayField: 'mname', listeners:{ expand:function(combo){ if(this.menu == null) { this.menu = showMenu; store.load(); }else{ grid.show(); } this.menu.showBy(this.el ); } } }); }
}]