【问题标题】:metadata configuration of fields in ExtJS DirectStoreExtJS DirectStore 中字段的元数据配置
【发布时间】:2011-01-19 15:05:12
【问题描述】:

我正在尝试从 ExtDirect 路由器加载网格数据。结果包含一个应该重新配置商店字段的元数据对象。但是,当我尝试加载数据时出现以下错误:

Uncaught TypeError: Cannot read property 'sortType' of undefined (ext-all-debug.js:23943)

JSON 结果是:

{
    "action": "Dashboard",
    "method": "dashboarddata",
    "type": "rpc",
    "result": {
        "success": true,
        "metaData": {
            "sortInfo": {
                "direction": "ASC",
                "field": "id"
            },
            "fields": [{
                "mapping": "id",
                "id": "id"
            },
            {
                "mapping": "owner",
                "id": "owner"
            },
            {
                "mapping": "name",
                "id": "name"
            },
            {
                "mapping": "type",
                "id": "type"
            },
            {
                "mapping": "strategy",
                "id": "strategy"
            },
            {
                "mapping": "primebroker",
                "id": "primebroker"
            },
            {
                "mapping": "startdate",
                "id": "startdate"
            },
            {
                "mapping": "date_afc_prelim_approval",
                "id": "date_afc_prelim_approval"
            },
            {
                "mapping": "date_afc_approval",
                "id": "date_afc_approval"
            },
            {
                "mapping": "date_submit_regulator",
                "id": "date_submit_regulator"
            },
            {
                "mapping": "date_approval_regulator",
                "id": "date_approval_regulator"
            },
            {
                "mapping": "enddate",
                "id": "enddate"
            },
            {
                "mapping": "main_iso_currency",
                "id": "main_iso_currency"
            },
            {
                "mapping": "nav_frequency",
                "id": "nav_frequency"
            },
            {
                "mapping": "date_first_nav",
                "id": "date_first_nav"
            },
            {
                "mapping": "launch_size",
                "id": "launch_size"
            },
            {
                "mapping": "target_size",
                "id": "target_size"
            },
            {
                "mapping": "memo",
                "id": "memo"
            },
            {
                "mapping": "isin_codes",
                "id": "isin_codes"
            },
            {
                "mapping": "status",
                "id": "status"
            }],
            "totalProperty": "total",
            "successProperty": "success",
            "idProperty": "id",
            "root": "data"
        },
        "data": [{
            "status": "Project closed",
            "strategy": "Strategy X",
            "date_afc_approval": "2010-01-01",
            "startdate": "2010-01-01",
            "nav_frequency": "Bi-monthly",
            "date_first_nav": "2010-01-01",
            "enddate": "2010-01-01",
            "date_approval_regulator": "2010-01-01",
            "id": "1",
            "date_afc_prelim_approval": "2010-01-01",
            "isin_codes": "123",
            "target_size": "2000",
            "owner": "Some name",
            "name": "First project",
            "memo": "TEXTEXTEXT",
            "main_iso_currency": "TND",
            "primebroker": "Yes",
            "date_submit_regulator": "2010-01-01",
            "launch_size": "1000",
            "type": "TypeX"
        }],
        "total": 1
    },
    "tid": 6
}

商店本身的配置如下:

var store = new Ext.data.DirectStore({
        idProperty: 'id'
        ,paramsAsHash: true
        ,directFn: MyApp.Direct.Dashboard.dashboarddata
        ,root:'data'
        ,autoLoad: false
        ,totalProperty:'total'
        ,fields: [
            {name: 'id', mapping: 'id'},
            {name: 'type', mapping: 'type'}
        ]
        ,baseParams: {
            type: this.type,
            filters: this.filters
        }
    });

谁能帮帮我?这让我发疯了,我看不出我做错了什么。

谢谢!

罗伯

PS。我正在使用 ExtJS 3.3.0

【问题讨论】:

    标签: javascript extjs


    【解决方案1】:

    为什么不使用 Chrome 或 Firefox 调试工具来调试那个地方呢?有用的选项是在 Chrome 中设置异常中断。

    【讨论】:

    • 嗯,试过调试 ExtJS 吗? :) 有很多代码行要逐步完成。无论如何,我认为这是我最好的选择。
    【解决方案2】:

    我修好了。调试成功了。

    显然,当通过 JSON 响应中的 metaData 对象更新字段时,您需要命名字段。 ExtJS 在内部使用名称字段作为查找字段。奇怪的是,使用商店字段的静态配置,您不需要该字段...

    ...
    "fields": [{
                    "mapping": "id",
                    "name": "id",
                    "id": "id"
                },
                {
                    "mapping": "owner",
                    "name": "owner",
                    "id": "owner"
                },
                ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-03
      • 1970-01-01
      • 2014-04-14
      • 1970-01-01
      • 2011-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多