0

使用以下用于生成模型和存储网格的代码片段,我收到了错误:

[W] Ext.data.Store created with no model. The name 'MyCompany.model.SomeModel' does not correspond to a valid model. ext-all-dev.js:12297
Uncaught TypeError: Cannot read property 'prototype' of undefined ext-all-dev.js:61224
    Ext.define.readRecords ext-all-dev.js:61224
    Base.implement.callParent ext-all-dev.js:6949
    Ext.define.readRecords ext-all-dev.js:61905
    Ext.define.read ext-all-dev.js:61195
    Ext.define.read ext-all-dev.js:102530
    Ext.define.load ext-all-dev.js:64125
    Base.implement.callParent ext-all-dev.js:6949
    Ext.define.load ext-all-dev.js:104696
    Ext.define.read ext-all-dev.js:63754
    Ext.define.constructor ext-all-dev.js:103732
    constructor ext-all-dev.js:8158
    (anonymous function)
    Ext.ClassManager.instantiate ext-all-dev.js:8908
    (anonymous function) ext-all-dev.js:3385
    (anonymous function) UserTraffic:401
    (anonymous function) ext-all-dev.js:16064
    fire ext-all-dev.js:16019
    Ext.apply.readyEvent.readyEvent.fire ext-all-dev.js:16277
    Ext.apply.fireReadyEvent ext-all-dev.js:16377
    (anonymous function)

代码:

Ext.onReady(function()
{
    var rawdata = [["2013-05-10T00:00:00",152,152,1643],["2013-05-11T00:00:00",5292,5292,51794] /* ... */ ];

    var model = Ext.define('MyCompany.model.SomeModel', {
        "fields": [
            {
                "dateFormat": "c",
                "mapping": 0,
                "name": "date",
                "type": "date"
            },
            {
                "mapping": 1,
                "name": "ActiveVisits",
                "type": "int"
            },
            {
                "mapping": 2,
                "name": "ActiveVisits",
                "type": "int"
            },
            {
                "mapping": 3,
                "name": "PageViews",
                "type": "int"
            }
        ],
        "extends": "Ext.data.Model"
    });


    var store = Ext.create('Ext.data.Store', {
        "data": rawdata,
        "proxy": { "type": "memory" },
        "id": "MyCompany.store.SomeModel",
        "sorters": [
            { "property": "date", "direction": "DESC" }
        ],
        "model": 'MyCompany.model.SomeModel',
        "requires": [ "MyCompany.model.SomeModel" ]
    });

    // ... clipped

});

我很难看到我错过了什么,提前感谢您的帮助!

我正在使用 ExtJs v4.2.1.883

4

1 回答 1

1

你的数字反射太敏锐了。

您键入extends而不是extend在模型定义中。extends是 Javascript 的保留(但未使用)关键字,因此 Ext 必须使用不太标准的名称...

仅供参考,您不需要将对象属性名称括在引号中,除非它们包含特殊字符:

{
    extend: '...' // that's ok
}
于 2013-06-10T16:45:13.013 回答