日期:2014-05-16  浏览次数:20302 次

关于Ext显示的格式问题!
最近在学习Ext,在网上下载了"掏钱学ExtJS",跟他上面的代码一样,但是显示却大相径庭...
代码如下:
HTML code

<html>

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=gbk">

        <title>grid</title>

        <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />

        <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>

        <script type="text/javascript" src="../../ext-all.js"></script>

        <script type="text/javascript">

Ext.onReady(function(){



    var cm = new Ext.grid.ColumnModel([

        {header:'编号',dataIndex:'id'},

        {header:'名称',dataIndex:'name'},

        {header:'描述',dataIndex:'descn'}

    ]);



    var data = [

        ['1','name1','descn1'],

        ['2','name2','descn2'],

        ['3','name3','descn3'],

        ['4','name4','descn4'],

        ['5','name5','descn5']

    ];



    var ds = new Ext.data.Store({

        proxy: new Ext.data.MemoryProxy(data),

        reader: new Ext.data.ArrayReader({}, [

            {name: 'id'},

            {name: 'name'},

            {name: 'descn'}

        ])

    });

    ds.load();



    var grid = new Ext.grid.GridPanel({

        el: 'grid',

        ds: ds,

        cm: cm

    });

    grid.render();



});

        </script>

    </head>

    <body>

        <script type="text/javascript" src="../examples.js"></script>

        <div id="grid"></div>

    </body>

</html>



例子运行的是正常如下:


但是我自己的却是如下:

为什么只是显示一行,末尾还有个下拉按钮

------解决方案--------------------
加个配置项:autoHeight:true,
JScript code

var grid = new Ext.grid.GridPanel({
        el: 'grid',
        autoHeight:true,
        ds: ds,
        cm: cm
    });