情况一:数据源store 不是从后台读取的 直接写的json字符串data用GridPanel显示数据 能完整的显示出数据
也不要设置GridPanel的高度height属性,能够根据读取的数据条数生成表格数 Ext.onReady(function() {
var data = [ [ '1', 'tom', '男', '29' ], [ '1', 'jack', '男', '25' ],
[ '1', 'lili', '女', '23' ] , [ '1', 'tom', '男', '29' ], [ '1', 'jack', '男', '25' ],
[ '1', 'lili', '女', '23' ] , [ '1', 'tom', '男', '29' ], [ '1', 'jack', '男', '25' ],
[ '1', 'lili', '女', '23' ] , [ '1', 'tom', '男', '29' ], [ '1', 'jack', '男', '25' ],
[ '1', 'lili', '女', '23' ] , [ '1', 'tom', '男', '29' ], [ '1', 'jack', '男', '25' ],
[ '1', 'lili', '女', '23' ] ];

var store = new Ext.data.SimpleStore( {
data : data,
fields : [ "id", "name", "sex", "age" ]
});
var grid = new Ext.grid.GridPanel({
                           title:"员工信息表",
       //height : 300,
       //width : 500,
store : store,
columns : [ 
            {header : "编号",dataIndex : "id"},
    {header : "用户名",dataIndex : "name"},
{header : "性别",dataIndex : "sex"}, 
    {header : "年龄",dataIndex : "age"}
    ],
bbar: new Ext.PagingToolbar({
            //pageSize: 6,
            store: store,
            displayInfo: true
        }),
renderTo:"hello"
});
});
情况一:数据是从后台取出来的:proxy: new Ext.data.HttpProxy({url: 'loginActiongetData.action'}),
用GridPanel显示数据 数据虽然加载出来了 但是表格数据没显示出来 必须要设置height属性来指定gridpanel的高度
才能显示数据    
 
Ext.onReady(function(){
   Ext.QuickTips.init();
    var GameRecord = Ext.data.Record.create([
        {name: 'productID', type: 'string'},
        {name: 'productName', type: 'string'},
        {name: 'productCode', type: 'string'}
        
    ]);

    var store = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({url: 'loginActiongetData.action'}),
        reader: new Ext.data.JsonReader({
      
        },GameRecord),
        remoteSort: true
    });      store.load();
  
    var grid = new Ext.grid.GridPanel({
        title: '交易信息列表',
        store: store,
        //width:700,
        //height:300,
        //autoHeight:false,
        columns:[
                  {header:'编号',dataIndex:'productID'},
      {header:'名称',dataIndex:'productName'},
      {header:'描述',dataIndex:'productCode'}
    ],
     
        bbar: new Ext.PagingToolbar({
            //pageSize: 6,
            store: store,
            displayInfo: true
        })
         ,renderTo:'grid3'
             });
});为何会出现这样啊???? 都是采用的gridpanel的来显示数据的 
为何情况一要不用设置高度height就能显示出数据 
而情况二却一定要设置高度height才能显示数据呢????????
这两种情况gridpanel部分完全一样
只有数据源store的获取方式不同而已

解决方案 »

  1.   

    gridpanel 如果不设置高度的话,那么他的高度就是由容器来决定的,如果数据已经有了,只是高度原因没显示的话,检查下容器的layout设置的对不对
      

  2.   


    我根本没设置layout啊  都是采用的容器gridpanel默认的  直接显示数据的 
    不知道为啥情况一要不用设置高度 情况二必须设置高度才能看到表格数据呢
      

  3.   

    我也遇到过这种情况,我用proxy时把height设置成auto就不能显示,自己定义高度后就可以显示了。可能和extjs的数据处理方式有关吧
      

  4.   

    恩就是啊  不知道是什么原因  希望那位extjs 高手能指点一下........
      

  5.   

    store.load()无法在grid.render()之前准备数组,所以也就无法知道grid的高度