2012-03-28 75 views
1

我是ExtJS的新手,並嘗試在網格底部添加一個按鈕。此按鈕將打開一個模式對話框以選擇更多人員。我不知道如何在網格後添加這個按鈕。我必須使用GridPanel以外的其他組件嗎?ExtJS 3.4在網格底部添加按鈕

有人可以幫我嗎?

代碼如下:

var selectedPersons = [ 
    [1, 'Persnr', 'Name', 'Vorname'] 
]; 

var store = new Ext.data.ArrayStore({ 
    fields: [ 
     {name: 'PrsOid', type: 'int'}, 
     {name: 'PersonalNr'}, 
     {name: 'Nachname'}, 
     {name: 'Vorname'} 
    ] 
}); 

store.loadData(selectedPersons); 

var grid = new Ext.grid.GridPanel({ 
    store: store, 
    columns: 
    [ 
     { 
      id  : 'PersonalNr', 
      header : 'PersonalNr', 
      width : 100, 
      sortable : true, 
      dataIndex: 'PersonalNr' 
     }, 
     { 
      header : 'Nachname', 
      width : 100, 
      sortable : true, 
      dataIndex: 'Nachname' 
     }, 
     { 
      header : 'Vorname', 
      width : 100, 
      sortable : true, 
      dataIndex: 'Vorname' 
     } 
    ], 
    stripeRows: true, 
    autoExpandColumn: 'PersonalNr', 
    height: 200, 
    //width: 460, 
    title: 'Personenauswahl', 
    // config options for stateful behavior 
    stateful: true, 
    stateId: 'grid' 
    }); 

    grid.render('gridSelectedPersons'); 

回答

3

你的意思是這樣一個底部欄?

var grid = new Ext.grid.GridPanel({ 
    store: store, 
    columns: 
    [ 
     .... 
    ], 
    stripeRows: true, 
    autoExpandColumn: 'PersonalNr', 
    bbar: new Ext.Toolbar({ 
     renderTo: document.body, 
     height: 30, 
     items: [ 
      // begin using the right-justified button container 
      '->', 
      { 
      xtype:'button', 
      text:'The button', 
      //makes the button 24px high, there is also 'large' for this config 
      scale: 'medium' 
      } 
     ] 
     }) 
+0

是的確切!現在我有一些設計問題:) 1.是否可以將按鈕放在右側? 2.我的圖標是24 x 24像素..此刻它將在按鈕內切割..是否有可能防止這種情況發生? BBAR: [ { 的xtype: '按鈕', 圖標: '缺勤/ IMG/addPersons.png', 處理程序:功能(){ showSelectPersonsPopup() } } ] – user886091 2012-03-28 12:23:37

+0

我已經編輯這些變化的答案 – nscrob 2012-03-28 12:57:29