1

私の出力 ![私の出力][1]

URLからネストされたjsonを解析しようとしましたが、完全に解析できず、利用可能なすべてのリンクを調べました: link1 link2 link3 link4

これは私の以前の質問でした

私のjsonは

({
"accountInfo": {
    "expire_date": "2014-07-02 08:01:09",
    "subscribe_date": "2013-07-02 08:01:09",
    "time_remain": " 355 Days 20 Hours 47 Minutes",
    "status": "not expired"
},
"status": "TRUE",
"message": "Todays Word",
"data": [
    {
        "name": "abacus",
        "author": "admin",
        "word_id": "2",
        "category": "Education",
        "definitions": [
            {
                "rating": "Green",
                "defintion": "replace \"my pc\" asdf edited",
                "def_id": "53",
                "example": null,
                "author": "admin"
            },
            {
                "rating": "This definition is not rated yet.",
                "defintion": "my new definition of word abacus",
                "def_id": "7",
                "example": null,
                "author": "admin"
            },
            {
                "rating": "This definition is not rated yet.",
                "defintion": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea, tempore labore veritatis maxime beatae est incidunt consectetur adipisci dolore reiciendis. Nostrum fugiat cumque beatae voluptatum.",
                "def_id": "45",
                "example": null,
                "author": "admin"
            },
            {
                "rating": "This definition is not rated yet.",
                "defintion": "this sub def will rep abacus' \"venture capitalist\"",
                "def_id": "31",
                "example": null,
                "author": "admin"
            }
        ],
        "is_favourite": "Yes"
    }
]
})

私のモデルは

Ext.define('Sencha.model.Menu', {
extend: 'Ext.data.Model',
config: {
    fields: [
        'name',
        'author',
        'word_id',
        'category',
      'data.definitions.definition'
    ],

    belongsTo: "Sencha.model.Contact"
}
});

Ext.define('Sencha.model.Contact', {
extend: 'Ext.data.Model',

requires: ['Sencha.model.Menu'],

config: {
    fields: [
        {name: 'status', mapping: 'status'},
        {name: 'message', mapping: 'message'},
        {name:'data', mapping: 'data'},
        {name: 'definitions', mapping: 'definitions.defintion'},
        {name: 'ratings', mapping: 'definitions.rating'},
       /* {name: 'definition', mapping: 'definitions'}*/
     /*{name: 'definition', mapping: 'data.definition.final_rating'}, json data     parsing My Favourite page and Today's word 65%*/
        

    ],
}
});

私の店

Ext.define('Sencha.store.Contacts', {
extend: 'Ext.data.Store',

config: {
    model: 'Sencha.model.Contact',
    autoLoad: true,
    //sorters: 'name',
    grouper: {
        groupFn: function(record) {
            return record.get('name')[0];
        }
    }
}
});

私の見解

Ext.define("Sencha.view.Main", {
extend: 'Ext.tab.Panel',
requires: ['Ext.TitleBar', 'Sencha.view.Contacts'],

config: {
    tabBarPosition: 'bottom',

    items: [
        {
            title: 'Contacts',
            iconCls: 'home',

            xtype: 'contacts'
        }
    ]
}
});

![i have been able to do upto this][7]
Ext.define('Sencha.view.Contacts', {
extend: 'Ext.List',
xtype: 'contacts',

config: {
    title: 'Stores',
    cls: 'x-contacts',

    store: 'Contacts',
    itemTpl: [

        '<div>',
            '<h2><b>Hello</b></h2>',
            '<tpl for="data">',
                '<div> - {name}</div>',
                '<div> - {author}</div>',
                '<div> - {word_id}</div>',
                '<div> - {category}</div>',
               '<div> - {definitions}</div>',
               
            '</tpl>',
        '</div>'
    ].join('')
}
});

私の出力は ![ここに画像の説明を入力][8] のはずでした

4

2 に答える 2

1

あなたが何を達成しようとしているのか正確にはわかりません。アプリケーションをローカルで再構築したところ、次の画面が表示されました。

スクリーンショット

私が行った唯一の大きな変更はjsonにあったと思います:

    [
    {
        "accountInfo": {
            "expire_date": "2014-07-02 08:01:09",
            "subscribe_date": "2013-07-02 08:01:09",
            "time_remain": " 355 Days 20 Hours 47 Minutes",
            "status": "not expired"
        },
        "status": "TRUE",
        "message": "Todays Word",
        "data": [
            {
                "name": "abacus",
                "author": "admin",
                "word_id": "2",
                "category": "Education",
                "definitions": [
                    {
                        "rating": "Green",
                        "defintion": "replace \"my pc\" asdf edited",
                        "def_id": "53",
                        "example": null,
                        "author": "admin"
                    },
                    {
                        "rating": "This definition is not rated yet.",
                        "defintion": "my new definition of word abacus",
                        "def_id": "7",
                        "example": null,
                        "author": "admin"
                    },
                    {
                        "rating": "This definition is not rated yet.",
                        "defintion": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea, tempore labore veritatis maxime beatae est incidunt consectetur adipisci dolore reiciendis. Nostrum fugiat cumque beatae voluptatum.",
                        "def_id": "45",
                        "example": null,
                        "author": "admin"
                    },
                    {
                        "rating": "This definition is not rated yet.",
                        "defintion": "this sub def will rep abacus' \"venture capitalist\"",
                        "def_id": "31",
                        "example": null,
                        "author": "admin"
                    }
                ],
                "is_favourite": "Yes"
            }
        ]
    }
]

試してみて、まだエラーがある場合、または何か他のものを探している場合はお知らせください。

がんばれ、ブラッド

于 2013-07-11T16:18:41.403 に答える