Я создаю приложение в Sencha Touch 2, используя обертку PhoneGap.
Я кодирую в модели MVC, вот ссылка на приложение в веб-сервере (для отладки): http://nqatalog.negroesquisso.pt/APP/ ВХОД: пользователь: 1, пароль: 1
У меня есть вложенный список с TreeStore для загрузки его данных и файл .json с данными.
Модель
Ext.define('APP.model.menuitem',{
extend: 'Ext.data.Model',
condig: {
fields: ['id', 'name', 'description', 'items']
}
});
Магазин
Ext.define('APP.store.nestedmenu', {
extend: 'Ext.data.TreeStore',
config: {
model: 'APP.model.menuitem',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'data/menu.json',
reader: {
type: 'json',
rootProperty: 'items'
}
}
}
});
View
Ext.define('APP.view.MenuNestedList', {
extend: 'Ext.dataview.NestedList',
xtype: 'menunestedlist',
id: 'debug',
config: {
store: 'nestedmenu'
},
});
Другой вид, вызывающий предыдущий
Ext.define("APP.view.Leftmenu", {
extend: 'Ext.Panel',
xtype: 'leftmenu',
config: {
items: [
{
xtype: 'menunestedlist'
}
],
listeners: {
painted: function () {
}
},
},
onleafitemtap: function() {}
});
Этот вложенный список отображается пустым (как вы можете видеть и отлаживать, если хотите по ссылке выше)
Спасибо за ваше время.
* РЕДАКТИРОВАТЬ (data / menu.json)
{
"items": [
{
"id": 1,
"name": "Section #1",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 8,
"name": "Product #1",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 9,
"name": "Product #2",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
},
{
"id": 2,
"name": "Section #2",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 3,
"name": "Section #3",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 10,
"name": "Product #3",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 11,
"name": "Product #4",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
},
{
"id": 4,
"name": "Section #4",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 12,
"name": "Product #5",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 13,
"name": "Product #6",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
},
{
"id": 5,
"name": "Section #5",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 14,
"name": "Product #7",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
},
{
"id": 6,
"name": "Section #6",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 15,
"name": "Product #8",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 16,
"name": "Product #9",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 17,
"name": "Product #10",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
}
]
},
{
"id": 7,
"name": "Section #7",
"description": "Lorem ipsum dolor sit",
"items": [
{
"id": 18,
"name": "Product #11",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 19,
"name": "Product #12",
"description": "Lorem ipsum dolor sit",
"leaf": true
},
{
"id": 20,
"name": "Product #13",
"description": "Lorem ipsum dolor sit",
"leaf": true
}
]
}
]
}