2011-06-21 71 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