2014-02-10 41 views
0

enter image description hereEXTJS重用別名成爲非功能性的標籤

我有默認4個標籤與車輛管理,駕駛員管理,位置管理,路由管理。
和我能夠重新車輛管理標籤 enter image description here

這是工具欄,我有提到,所以當我們創建一個新的車輛管理選項卡,將導致非功能所有選項卡的工具欄。也許我在新的車輛管理中重新使用網格面板?

這裏是我的示例代碼:

vehicle.js

Ext.define('MyApp.view.MyVehicleGridPanel', { 
    extend: 'Ext.grid.Panel', 
    id : 'mygridpanel', 
    //renderTo : 'vehiclebody', 
    alias: 'widget.mygrid', 
    header: false, 
    store: UserStore, 
    multiSelect: false, 
    columns: [ 
       { 
        xtype: 'gridcolumn', 
        dataIndex: '_id', 

        text: 'Vehicle ID' 
       }, 
       { 
        xtype: 'gridcolumn', 
        width: 126, 
        dataIndex: 'Plat_No', 
        text: 'Plat Number' 
       }, 
       { 
        xtype: 'gridcolumn', 
        width: 200, 
        dataIndex: 'Name', 
        text: 'Added By' 
       } 
] 
}) 

當用戶點擊toorbar將再次使用別名mygrid

這是我的工具欄的代碼:

var BtnVehicle = Ext.getCmp('BtnVehicle'); 
    BtnVehicle.on('click', function(){ 
     tabs.add({ 
      closable: true, 
      xtype : 'mygrid', 
      //html: '<div style="width:100%; height:100%; background-color:#cccccc;"><iframe src="vehicle/vehicle.html" frameborder=0 scrolling="no" style="width:100%; height:100%;"></iframe></div>', 
      iconCls: 'bus32', 
      title: 'Vehicle Manage' 
     }).show(); 
    }) 

只要用戶能夠以相同的設計相同的GridPanel創建無限制選項卡。

怎麼來的時候創建第二個相同的xtype: 'mygrid'然後該標籤將變得不起作用?從GridPanel配置

+1

不要在GridPanel中使用'id'例如id:'mygridpanel'' – MMT

+0

@MMT如果沒有'id'我怎麼能像'var grid = Ext.getCmp('mygridpanel')那樣獲取gridpanel? ?有其他方法嗎? –

+0

檢查[Ext.ComponentQuery](http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.ComponentQuery) – MMT

回答

1

刪除id,而不是在文檔中使用itemId & 搜索組件內Ext.ComponentManager(全局)或特定用Ext.container.Container類似的語法使用Ext.ComponentQuery

參閱CSS選擇docs