2013-07-25 204 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