Hi,
I have a json like this:

Code:
{ "Categories": [ { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 7, "InternalName": "items", "Name": "" }, "children": [ { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 2, "InternalName": "CASE Corporate", "Name": "Corporate" }, "children": [ { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 10, "InternalName": "test1", "Name": "test1" }, "children": [ { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 12, "InternalName": "subsub", "Name": "subsub1" }, "children": [ ] }, { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 16, "InternalName": "nvcxhgfx", "Name": "nvcxhgfx" }, "children": [ ] } ] }, { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 11, "InternalName": "test12a", "Name": "test12en" }, "children": [ ] } ] }, { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 3, "InternalName": "Job Site", "Name": "Job report" }, "children": [ { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 17, "InternalName": "nvcxhgfxggg", "Name": "nvcxhgfx" }, "children": [ ] } ] }, { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 4, "InternalName": "CASE Dealers", "Name": "Dealers" }, "children": [ ] }, { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 5, "InternalName": "Events", "Name": "Events" }, "children": [ ] }, { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 6, "InternalName": "Show", "Name": "Shows" }, "children": [ ] } ] }, { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 8, "InternalName": "management", "Name": "" }, "children": [ ] }, { "item": { "Description": "", "Media": null, "ItemCount": 0, "Id": 9, "InternalName": "multimedia", "Name": "" }, "children": [ ] } ] }

where I have a nested structure of objects compose of item and children, each children is a collection of item and children as well.

I set up the store like this

Code:

Code:
Ext.define('MyApp.store.Categories', {
    extend: 'Ext.data.TreeStore',
    alias: 'store.categoriesStore',


    requires: [
        'MyApp.model.CategoryTree'
    ],


    config: {
        model: 'MyApp.model.CategoryTree',
        storeId: 'categoriesStore',
        nodeParam: 'children',
        proxy: {
            type: 'ajax',
            url: 'http://domain/Presskit/front/api/category/GetAllCategories',
            reader: {
                type: 'json',
                rootProperty: 'Categories'
            }
        }
    }
});


and the models like this:

Code:

Code:
Ext.define('MyApp.model.CategoryTree', {
    extend: 'Ext.data.Model',


    uses: [
        'MyApp.model.Category'
    ],


    config: {
        hasMany: {
            associationKey: 'children',
            model: 'MyApp.model.CategoryTree',
            autoLoad: true,
            name: 'children'
        },
        hasOne: {
            associationKey: 'item',
            model: 'MyApp.model.Category'
        }
    }
});


Ext.define('MyApp.model.Category', {
    extend: 'Ext.data.Model',


    uses: [
        'MyApp.model.CategoryTree'
    ],


    config: {
        fields: [
            {
                name: 'Name'
            },
            {
                name: 'InternalName'
            },
            {
                name: 'Id'
            },
            {
                name: 'Media'
            },
            {
                name: 'ItemCount'
            },
            {
                name: 'Description'
            }
        ],
        belongsTo: {
            model: 'MyApp.model.CategoryTree',
            primaryKey: 'Id'
        }
    }
});


But it doesn't seam to work properly.
What is the correct implementation for the model?