帮助运行简单的Ext JS示例?

时间:2011-09-01 02:09:07

标签: extjs

我下载了Ext JS 4.0.2a,我正在尝试使用Ext JS教程。我去了“必需品”的例子,所以我很确定我的设置正确。我正在尝试在这里做网格示例...

http://www.sencha.com/learn/legacy/Tutorial:Getting_Productive

...但我无法显示网格。

我的ExtStart.html如下所示:

<html>
<head>
    <title>Introduction to Ext 2.0: Starter Page</title>

    <!-- Include Ext and app-specific scripts: -->
    <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="ExtStart.js"></script>

    <!-- Include Ext stylesheets here: -->
    <link rel="stylesheet" type="text/css" href="../resources/css/ext-all.css">
    <link rel="stylesheet" type="text/css" href="ExtStart.css">
</head>
<body>

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

</body>
</html>

和我的ExtStart.js就像在教程网站上一样:

Ext.onReady(function() {
    // sample static data for the store
    var myData = [['Apple',29.89,0.24,0.81,'9/1 12:00am'],
        ['Ext',83.81,0.28,0.34,'9/12 12:00am'],
        ['Google',71.72,0.02,0.03,'10/1 12:00am'],
        ['Microsoft',52.55,0.01,0.02,'7/4 12:00am'],
        ['Yahoo!',29.01,0.42,1.47,'5/22 12:00am']
    ];

    // create the data store
    var ds = new Ext.data.ArrayStore({
        fields: [
           {name: 'company'},
           {name: 'price', type: 'float'},
           {name: 'change', type: 'float'},
           {name: 'pctChange', type: 'float'},
           {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
        ]
    });

    // manually load local data
    ds.loadData(myData);

    // create the colum Manager
    var colModel = new Ext.grid.ColumnModel([
            {header: 'Company', width: 160, sortable: true, dataIndex: 'company'},
            {header: 'Price', width: 75, sortable: true, dataIndex: 'price'},
            {header: 'Change', width: 75, sortable: true, dataIndex: 'change'},
            {header: '% Change', width: 75, sortable: true, dataIndex: 'pctChange'},
            {header: 'Last Updated', width: 85, sortable: true,
                renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
    ]);


    // create the Grid
    var grid = new Ext.grid.GridPanel({
        store: ds,
        colModel: colModel,
        height: 300,
        width: 600,
        title: 'My First Grid'
    });

    // render the grid to the specified div in the page
    grid.render('grid-example');
});

任何想法我可能做错了什么?可悲地难倒。 :(

抢劫

1 个答案:

答案 0 :(得分:5)

您使用的是ExtJS4,但指的是旧版文档。

对组件进行了相当多的更改,以及如何在为您编写的文档版本和您正在使用的版本4之间将它们连接在一起。

这是ExtJS 4的数组网格(和其他)示例。

HTML
Javascript code

例如,您使用的是Ext.grid.GridPanel。这不再有效。 (改为使用Ext.grid.Panel