当前位置:   article > 正文

grid.getSelectionModel()的所有操作

getselectionmodel

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);//取消指定行的记录
  1. var data = {users:[
  2. {mid:'1',mname:'非诚勿扰'},
  3. {mid:'2',mname:'让子弹飞'},
  4. {mid:'3',mname:'锦衣卫'},
  5. {mid:'4',mname:'狄仁杰4'}
  6. ]}

  7. var store = new Ext.data.Store({
  8. fields:['mname','mid'],
  9. data : data,
  10. proxy: {
  11. type: 'memory',
  12. reader: {
  13. type: 'json',
  14. root: 'users'
  15. }
  16. }
  17. });
  18. //combox弹出
  19. var grid = new Ext.grid.GridPanel({
  20. width:100,
  21. height: 200,
  22. store: store,
  23. viewConfig:{
  24. forceFit:true
  25. },
  26. columns:[{header:'姓名',dataIndex:'mname',width: 90}
  27. ],
  28. selType:'checkboxmodel',//设定选择模式
  29. multiSelect:true,//运行多选
  30. dockedItems: [{
  31. xtype: 'toolbar',
  32. dock: 'bottom',
  33. items: [
  34. {xtype: 'button', text: '确定',handler:function(){
  35. var m = grid.getSelectionModel().getSelection();
  36. var ids = [];
  37. for(var i=0;i<m.length;i++){
  38. ids.push(m<i>.get('id'));
  39. }grid.hide()}},
  40. {xtype: 'button', text: '取消',handler:function(){
  41. grid.hide();
  42. }}
  43. ]
  44. }]
  45. });

  46. var showMenu = new Ext.menu.Menu({
  47. items : [grid]
  48. });
  49. panel = Ext.create('Ext.form.Panel', {
  50. 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 ); } } }); }
  51. }]
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<m.length;i++){
     ids.push(m<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 );            }        }            });          }
  }]
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/111814
推荐阅读
相关标签
  

闽ICP备14008679号