2014-02-06 68 views
0

我有一个两个GridPanel,即:'grid1'和'grid'在我的mainPanel下。现在,无论何时点击或选择我的'grid1'面板中的数据,我都希望这些数据也出现在我的'网格'面板中,这就是我的问题。Extjs Grid Panel Rowclick

这是我到目前为止已经试过:

 var grid1 = new Ext.grid.EditorGridPanel({ 
       id: 'editorgrid', 
       store: store1, 
       title: 'Animals', 
       cm: cm1, 

       width: 400, 
       anchor: '100%', 
       height: 700, 

       frame: true, 
       loadMask: true, 
       waitMsg: 'Loading...', 
       clicksToEdit: 1, 
       tbar: [ 
       'Animals Unit : ', '-',    
       { 
       xtype: 'combo', 
       name: 'animal_combo', 
       id:'cboAnimal', 
       anchor: '90%', 
       allowBlank: false, 
       editable: false, 
       forceSelection: true, 
       triggerAction: 'all', 
       mode: 'remote', 
       store: new Ext.data.JsonStore({ 
        url: '/index.php/getAnimalCombo', 
        root: 'data', 
        totalProperty: 'total', 
        fields: ['id','desc'], 
        params: {start: 0}, 
        baseParams: {limit: 25} 
       }), 
       pageSize: 25, 
       displayField: 'desc', 
       valueField: 'id', 
       minListWidth: 150, 
       valueNotFoundText: '', 
       width: 150, 
       minChars: 1 

       }, 

       '-', 

       ],     
      bbar: pager1 
      }); 

       Ext.getCmp('cboAnimal').addListener('select', function(combo, record, index){ 

        grid1.getStore().baseParams['animal_id'] = record.get('id'); 
        grid1.getStore().load(); 
       }); 






       var store = new Ext.data.JsonStore({ 
       proxy: new Ext.data.HttpProxy({ 
         url: '/index.php/getContent' 

        }), 
        root: 'data', 
        pruneModifiedRecords: true, 
        totalProperty: 'total', 
        baseParams: {limit: 25}, 
        autoLoad: {params: {start: 0}}, 
        fields: ['id','animals'], 
        sortInfo: {field:'id', direction:'ASC'} 

      }); 


       var grid = new Ext.grid.EditorGridPanel({ 
       id: 'maingrid', 
       store: store, 

       cm: cm, 

       width: 785.5, 
       anchor: '100%', 
       height: 700, 

       frame: true, 
       loadMask: true, 
       waitMsg: 'Loading...', 
       clicksToEdit: 1, 
       bbar: pager 
      }); 
+2

我建议你使用jsfiddle向我们展示它不起作用。这样我们可以更容易地为您提供工作代码。 –

+0

有人对我说,也许我必须使用'rowClick'。 – sack

回答

1

试试这个,让我知道结果...

// instead of baseParam try to use extraParams 
grid1.getStore().proxy.extraParams = {'animal_id': record.get('id')} 

另外,请写出错误消息或什么你越来越!

+0

有一个错误,ReferenceError:没有定义记录 – sack