2013-07-25 107 views
3

我有以下電網這裏:添加工具欄到網格 - ExtJS的

Ext.define('AM.view.user.List', { 
    extend: 'Ext.grid.Panel', 
    alias: 'widget.userlist', 
    title: 'All Users', 
    store: 'Users', 

    initComponent: function() { 
     this.columns = [{ 
      header: 'Name', 
      dataIndex: 'name', 
      flex: 4 
     }, { 
      header: 'User ID', 
      dataIndex: 'user_id', 
      flex: 1 
     }, { 
      header: 'Address', 
      dataIndex: 'address', 
      flex: 3 
     }, { 
      header: 'Age', 
      dataIndex: 'agee', 
      flex: 5 
     }]; 

     this.callParent(arguments); 
    } 
}); 

可以一個工具欄添加到該網格的底部或可它們只能被添加到面板?

另外,如何將正常的文本放在工具欄而不是按鈕?

回答

15

是一個網格面板繼承Ext.grid.Panel,你應該能夠補充:

dockedItems: [{ 
    xtype: 'toolbar', 
    dock: 'top', 
    items: [{ 
     xtype: 'button', 
     text: 'Left Button' 
    }, { 
     xtype: 'tbfill' 
    }, { 
     xtype: 'button', 
     text: 'Right Button' 
    }] 
}] 
+0

嘿感謝這偉大的工作。我會檢查文檔。 –

+0

如何將工具欄按鈕放置在左側和右側? –

+1

在工具欄中的按鈕配置之間添加{xtype:'tbfill'} – BigBadOwl

2

或者您也可以使用添加按鈕'bbar[...]'相當於

dockedItems: [{ 
    xtype: 'toolbar', 
    dock: 'bottom', 
    items: [ 
     { xtype: 'button', text: 'Button 1' } 
    ] 
}] 

這可以讓你在您的網格面板的底部允許使用所有其他按鈕屬性。

示例代碼是在這裏:

bbar: [ 
     { xtype: 'button', text: 'Button 1' }, 
     { xtype: 'button', text: 'Button 2' } 
    ] 

,瞭解詳情可以參考文檔:http://docs.sencha.com/extjs/6.0/6.0.1-classic/#!/api/Ext.panel.Panel-cfg-bbar