日期:2014-05-17  浏览次数:20684 次

ExtJs表格没有显示数据
菜鸟求助,为什么下面的代码没有显示。求解。。。。。
JS如下:
JScript code

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 store = new Ext.data.Store({
        proxy:new Ext.data.MemoryProxy(data),
        reader:new Ext.data.ArrayReader([
                {name:'id'},
                {name:'name'},
                {name:'descn'}
            ])
    });

    store.load();

    var grid = new Ext.grid.GridPanel({
        renderTo:'grid',
        store:store,
        cm:cm
    });
});



HTML如下:
HTML code

<html>
    <head>    
       <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <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-debug.js"></script>
        <script type="text/javascript" src="Hello.js"></script>
        <script type="text/javascript" src="../../source/locale/ext-lang-zh_CN.js"></script>
    </head>
    <body>
        <div id='grid'></div>
    </body>
</html>



结果如下:


------解决方案--------------------
var cm = new Ext.grid.ColumnModel([
{header:'编号',dataIndex:'id'},
{header:'名称',dataIndex:'name'},
{header:'描述',dataIndex:'descn'}
]);
把这一部分放到
var store = new Ext.data.Store({
proxy:new Ext.data.MemoryProxy(data),
reader:new Ext.data.ArrayReader([
{name:'id'},
{name:'name'},
{name:'descn'}
])
});
后面,dataIndex:''指向已经定义好的列,你都没定义,怎么使用