0

ネストされたリストをSenchaアプリにロードしようとしています。問題は、私がそれに精通しておらず、使用しているjsonファイルが正しいかどうかわからないことです。

[
    {
        "text":[


            {
                "text":"1.1.1",
                "leaf":true

            }],
        "text":[

            {
                "text":"1.1.1",
                "leaf":true

            }
        ]


    }
]

これは私のストアコードです

//Defining the store for the Nested List
Ext.define('InfoImage.store.nestedListStore', {
    extend: 'Ext.data.TreeStore',
    requires: 'InfoImage.model.nestedListModel',
    id:'nestedListStore',
    config:{

        //Calling the required model for the Work Item List
        model : 'InfoImage.model.nestedListModel',
        //Defining the proxy for the Work Item List to pull the data for the List
        proxy : {
            type : 'ajax',
            url : 'app/model/data/list.json',
            reader: {
                type: 'json',
                root: 'items'

            }
        },
        autoLoad: true


    }
});

私のメインコードは

Ext.define("InfoImage.view.nestedList", {
    extend:'Ext.NestedList',
    xtype:'nestedList',
    id:'nestedList',

    config:{
        fullscreen:'true',
        title:'Nested List',
        xtype:'nestedList',
        //displayField : 'text',
        html:'Nested List on its way!!!',
        store:'nestedListStore'
        //itemTpl:'{text}'
    }
});

表示される出力は[オブジェクトオブジェクト]です。何が欠けているのかわかりません。助けていただければ幸いです。

4

2 に答える 2

1

まず、あなたのJsonは有効なjsonです。jsonlint.comにjsonを貼り付けて、常に有効なjsonを確認してください

第二に、あなたがコメントアウトしたことがわかります

displayField:'text' 

財産。を指定しないと、データストアのどのアイテムをリストに表示displayFieldするnestedlistかがわかりません。

[object Object]おそらく、それがリストのo/pとしてを取得している理由です。

上記の行のコメントを外して確認してください。

于 2012-04-26T13:03:20.890 に答える
0

はモデルのフィールドであり、JSONファイルでrootPropertyとして宣言するべきではないため、JSONは機能しないようExt.NestedListです。text

まず、次のモデル定義があると仮定します。

Ext.define('ListItem', {
    extend: 'Ext.data.Model',
    config: {
        fields: ['text']
    }
});

データによると、JSONファイルは次のようになります。

items: [
{
    text: '1.1',
    items: [
    { text: '1.1.1', leaf: true },
    { text: '1.1.2', leaf: true }
    ]
    }
]

この構成をストアにも追加する必要がありますdefaultRootProperty: 'items'

于 2012-04-27T04:08:39.093 に答える