2013-01-18 123 views
2
傳遞參數窗口面板
{ 
    icon: 'images/delete.png', 
    tooltip: 'Edit', 

    handler: function(grid, rowIndex, colIndex) { 
      var edit = Ext.create('AM.view.user.Uploadfile').show(); 
      //here I want to pass parameters to get in window panel  
    } 
} 

,我已經寫了,並希望傳遞類似的行id其中點擊窗口面板上的圖標的參數的代碼。從網格面板中EXTJS4

+0

爲什麼有你的處理程序,它的參數?你能詳細說明那個按鈕嗎? – sra

+0

實際上它在網格佈局下,我使用一個按鈕作爲動作列。我想在點擊它到窗口面板時傳遞'id'。 – anupkumar

回答

0

這是一個動作列上的按鈕。要將Id傳遞給窗口,您可以通過從記錄參數獲取行數據來檢索行數據。

columns: [ 
    { text: 'Id', dataIndex: 'Id', width: 50 }, 
    { 
     xtype: 'actioncolumn', 
     width: 100, 
     text: 'Delete', 
     align: 'center', 
     items: [{ 
      icon: '../images/delete.png', 
      tooltip: 'Delete', 
      handler: function (grid, rowIndex, colIndex, item, e, record) { 
       myWin.id = record.data.Id; //where myWin is a reference to the window object and id is just a config. 
      } 
     }] 
    } 
] 
+0

上面的代碼贏得了什麼= Ext.getCmp('somewindow');意味着這裏。 – anupkumar

+0

供參考:'rowIdenx'不一定需要是商店內記錄的索引。至少我從來沒有聽說過這樣的公約。即使可能在某些情況下我也不會依賴它,直到它們將其重命名爲recordIndex;) – sra

+0

謝謝sra。我在開發中有這樣的代碼:o,我現在要用你的例子修復它:) – A1rPun

1

如果你看一下API,你會看到handler有爭論

  • 觀:擁有的TableView。
  • rowIndex:點擊行索引。
  • colIndex:點擊列索引。
  • item:被點擊的項目(或者這個Column如果沒有配置多個項目)。
  • e:點擊事件。
  • 記錄:記錄的點擊排

其中最後一個是有趣的,你根本。所以,你可以像這樣

handler: function(grid, rowIndex, colIndex, item, e , record) { 
    var win = Ext.create('Ext.window.Window', { 
      autoShow: true, 
      html: record.data.firstname + ' ' + record.data.lastname 
    }); 
} 

這裏是一個工作JSFiddle