簡體   English   中英

根數據extjs外部的嵌套JSON訪問

[英]Nested JSON access outside of root data extjs

我有一個模型和商店,如下所示:

Ext.define('Cookbook.model.List', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'key', type: 'int' },
        { name: 'title' }
    ],

    proxy: {
        type: 'ajax',
        url: global.baseUrl + '/api/cookbook/1/1/8/8/-1?take=30',
        totalProperty: 'TotalRecordCount',
        reader: {
            type: 'json',
            root: 'Data'
        }
    }
});


Ext.define('Cookbook.store.Lists', {
    extend: 'Ext.data.TreeStore',
    model: 'Cookbook.model.List',

    root: {
        expanded: true,
        id: -1,
        name: 'All Lists'
    }

});

它正在處理的json的結構如下所示:

{"Data":
[{"title":"0 0asample cookbook","key":629},
[{"title":"0 0asample cookbook1","key":6291}],
"Count":568}

現在我的問題是:即使其根在Data上,也可以使用列表存儲來訪問計數嗎?

我嘗試添加count屬性,但未獲得所需的結果。 我設法通過使用下面的代碼檢索數據:

var st = Ext.getStore('Lists');
st.getProxy().getReader().rawData.totalCount

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM