怎么获取Editor每一行的控件了?比如combobox

解决方案 »

  1.   

    grid.getColumnModel().getCellEditor(colIndex);
      

  2.   

    可以写在cellclick事件中,这样就可以找到每个单元格的editor
     cellclick: function(grid, rowIndex, columnIndex, e) {
           var editor = grid.colModel.getCellEditor(columnIndex, rowIndex);
      }
      

  3.   

    我在第一个combobox里加了select事件
    select:function(com){
       var v = grid.getColumnModel.getCellEditor(colIndex,rowIndex);
       v.field.store = new Ext.data.Store({});
    }
    像是这样的.  第选择一个都去入到入台.在后台输出都是对的.
    但第二个combobox显示的还是一样
    我一会把原码贴一下。大家帮我看看. 谢谢两位的关注啊..
      

  4.   

    这源码Ext.onReady(function(){
    var row;
    var sm = new Ext.grid.CheckboxSelectionModel();
    var sxlxStore = new Ext.data.JsonStore({
    url:'../../bm23sxlxManager.do?method=dofindAll',
    method:'post',
    root:'data',
    totalProperty:'results',
    id:'scm',
    fields:[{name:'scm',mapping:'scm',type:'int'},{name:'name',mapping:'name',type:'string'}]
    });
    var sxTypeStore = new Ext.data.JsonStore({
    url:'../../bm23SxTypeManager.do?method=doGetSxName',
    method:'post',
    root:'data',
    id:'sx_type_scm',
    fields:[{name:'sx_type_scm',mapping:'scm',type:'int'},{name:'name',mapping:'name',type:'string'}]
    });
    sxlxStore.load();
    var cm = [
      new Ext.grid.RowNumberer(),sm,
    {dataIndex:'scm',hidden:true},
    {
    header:'属性',dataIndex:'sxlx_scm',width:100,
    editor:new Ext.grid.GridEditor(new Ext.form.ComboBox({
      allowBlank:false,
      store:sxlxStore,
      mode:'local',
      emptyText:'请选择',
      valueField:'scm',
      triggerAction : 'all',
      displayField:'name',
      listeners:{
      select:function(com){
      var v = sxGrid.getColumnModel().getCellEditor(5,row);
      v.field.store = new Ext.data.JsonStore({
    url:'../../bm23SxTypeManager.do?method=doGetSxName',
    method:'post',
    root:'data',
    //totalProperty:'results',
    id:'sx_type_scm',
    fields:[{name:'sx_type_scm',mapping:'scm',type:'int'},{name:'name',mapping:'name',type:'string'}],
    baseParams:{type:com.getValue()}
    });
      v.field.store.load();
      }
      }
    })),
    renderer:function(value){
    var index = sxlxStore.find('scm',value);
    if(index!=-1)
    return sxlxStore.getAt(index).data.name;
    return value;
    }
    },{
    header:'科目号',dataIndex:'KMH',width:100,
    editor:new Ext.grid.GridEditor(new Ext.form.TextField({
    allowBlank:false
    }))
    },{
    header:'名称',dataIndex:'name',width:100,
    editor:new Ext.grid.GridEditor(new Ext.form.ComboBox({
    allowBlank:false,
    emptyText:'请选择',
    valueField:'sx_type_scm',
    triggerAction : 'all',
    mode:'local',
       displayField:'name',
    store:sxTypeStore
    }))
    },{
    header:'备注',dataIndex:'bz',width:100,
    editor:new Ext.grid.GridEditor(new Ext.form.TextField({
    allowBlank:false
    }))
    }
    ];
    var myData=[['','','','','']]
    var sxStore = new Ext.data.ArrayStore({
    fields:[
    {name:'scm'},
    {name:'name'},
    {name:'KMH'},
    {name:'sxlx_scm'},
    {name:'bz'}
    ]
    });
    var sxGrid = new Ext.grid.EditorGridPanel({
    clicksToEdit: 1,
    store:sxStore,
    sm:sm,
    cm:new Ext.grid.ColumnModel(cm),
    listeners:{
    rowmousedown:function(grid,rowIndex,e){
    row=rowIndex;
    }
    },
      viewConfig:{
      forceFit:true
      }
      });
    });
      

  5.   

    var cm = new Ext.grid.ColumnModel([{
               id:'common',
               header: "Common Name",
               dataIndex: 'common',
               width: 220,
               editor: new fm.TextField({
                   allowBlank: false
               })
            },{
               header: "Light",
               dataIndex: 'light',
               width: 130,
               editor: new Ext.form.ComboBox({
                   typeAhead: true,
                   triggerAction: 'all',
                   transform:'light',
                   lazyRender:true,
                   listClass: 'x-combo-list-small',
                   listeners: {
                          select:function(com){
                              var v = grid.getColumnModel.getCellEditor(colIndex,rowIndex);
                              v.field.store = new Ext.data.Store({});
                           }//这样就为每个combox添加了事件了
                   }
                })
            }
      

  6.   


     var v = sxGrid.getColumnModel().getCellEditor(5,row);
                              v.field.store = new Ext.data.JsonStore({
                                url:'../../bm23SxTypeManager.do?method=doGetSxName',
                                method:'post',
                                root:'data',
                                //totalProperty:'results',
                                id:'sx_type_scm',
                                fields:[{name:'sx_type_scm',mapping:'scm',type:'int'},{name:'name',mapping:'name',type:'string'}],
                                baseParams:{type:com.getValue()}
                            });
                              v.field.store.load();这里得到了相应行的第二个combobox也进入后台了.测试输出数据也正确
    可就是显示的一样.
      

  7.   

    select:function(grid, rowIndex, columnIndex, e) {//这样参数就不固定了
      var editor = grid.colModel.getCellEditor(columnIndex, rowIndex);
      }
      

  8.   

    只要后台数据库的数据被改变了,reload下grid的数据应该就是改变后的了 
      

  9.   

    我把 v.field.store.load();改为reload().还是一样.