Okay, I got it to work with a simple list and a normal store.
Nested data still doesn't work ...
The list gets filled with the category names, but the items don't have any sub items, so the hasMany relation does not seem to work correctly, but I have no clue what I am doing wrong ...
So here is my basic json structure:
Code:
{ "categories": {
"category": [
{
"@id": "6",
"name": "Allgemeines",
"description": "Seitenübergreifende Themen",
"boards": {
"board": [
{
"@id": "95",
"name": "3DSupply.de",
"description": "Alles rund um 3D Supply"
},
{
"@id": "69",
"name": "MTA-Lan",
"description": "Lanparty im Feriendorf"
}
]
}
},
{
"@id": "7",
"name": "Counter-Strike / Half-Life 2",
"description": "Alles rund um Valves Spiele",
"boards": {
"board": [
{
"@id": "18",
"name": "Hauptforum",
"description": "Alles rund ums Thema Counter-Strike!"
},
{
"@id": "19",
"name": "CS-Help",
"description": "Sorgen und Nöte mit CS?"
}
]
}
}
]
}
}
store.Category
Code:
Ext.define('blueMobile.store.Category', { extend: 'Ext.data.Store',
requires: ['blueMobile.model.Category'],
config: {
autoLoad: true,
model: 'blueMobile.model.Category',
storeId: 'Category',
proxy: {
type: 'ajax',
url: '/php/boards.json',
reader: {
type: 'json',
rootProperty: 'categories.category'
}
}
}
});
model.Category
Code:
Ext.define('blueMobile.model.Category', { extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'id', mapping: '@id' },
'name',
'description'
],
hasMany: {
associatedModel: 'blueMobile.model.Board',
}
}
});
model.Board
Code:
Ext.define('blueMobile.model.Board', { extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'id', mapping: '@id' },
'name',
'description'
],
proxy: {
reader: {
type: 'json',
rootProperty: 'boards.board'
}
},
belongsTo: 'Category'
}
});