2011-06-21 39 views
1

我想在一個標籤內放置一個網格(Ext.grid.GridPanel)對象。標籤內部的網格

這是代碼:

var grid = new Ext.grid.GridPanel({ 
    store: new Ext.data.Store({ 
     autoDestroy: true, 
     reader: reader, 
     data: xg.dummyData 
    }), 
    colModel: new Ext.grid.ColumnModel({ 
     defaults: { 
      width: 120, 
      sortable: true 
     }, 
     columns: [ 
      {id: 'company', header: 'Company', width: 200, sortable: true, dataIndex: 'company'}, 
      {header: 'Price', renderer: Ext.util.Format.usMoney, dataIndex: 'price'}, 
      {header: 'Change', dataIndex: 'change'}, 
      {header: '% Change', dataIndex: 'pctChange'}, 
      // instead of specifying renderer: Ext.util.Format.dateRenderer('m/d/Y') use xtype 
      { 
       header: 'Last Updated', width: 135, dataIndex: 'lastChange', 
       xtype: 'datecolumn', format: 'M d, Y' 
      } 
     ] 
    }), 
    sm: new Ext.grid.RowSelectionModel({singleSelect:true}), 
    width: 600, 
    height: 300, 
    frame: true, 
    title: 'Framed with Row Selection and Horizontal Scrolling', 
    iconCls: 'icon-grid' 
}); 

this.tabs = new Ext.TabPanel({ 
    fullscreen: true, 
    type: 'dark', 
    sortable: true, 
    dockedItems: [ 
    { 
     xtype:'toolbar', 
     title:'Hello World' 
    }], 
    tabBar: { 
     ui: 'light', 
     layout: { 
      pack: 'left' 
     } 
    }, 
    items: [ 
    { 
     cls:'hello', 
     id:'tab1', 
     html : '<a>hello</a>', 
     title:'Monitor' 
    }, { 
     cls:'world', 
     id:'tab2',  
     xtype: 'map',     
     html : '<a>hello world</a>', 
     title:'Map' 
    }, { 
     cls:'world', 
     id:'tab3',         
     html : '<a>hello world</a>', 
     dockedItems:grid 
    }] 
});  

當我加載網頁沒有錯誤,但網格沒有顯示。

回答

3

網格不是一個停靠項目(這是工具欄和其他東西,應該堅持容器的一側)。如果你想在網格佔據整個標籤,只需直接將其添加爲到的TabPanel一個項目,它將成爲全片:

items: [ 
{ 
    cls:'hello', 
    id:'tab1', 
    html : '<a>hello</a>', 
    title:'Monitor' 
}, { 
    cls:'world', 
    id:'tab2',  
    xtype: 'map',     
    html : '<a>hello world</a>', 
    title:'Map' 
}, 
grid ] 
+0

我試圖添加這樣的,但它顯示只有兩個選項卡。網格未連接到選項卡面板 – lakshmi

+0

我已將網格直接添加到選項卡面板,現在它已經工作。它已經添加到Tab中。但標籤標題爲空。如何設置標籤標題。 – lakshmi

+0

我剛剛在網格中添加了標題。它的作品適合我。 Thaks很多Mr.bmoeskau。 – lakshmi