我最近开发了一个关于显示类别/子类别的煎茶应用程序。它显示主要类别,但在单击任何类别时不显示子类别。
我的店是——
Ext.define('listdemo.store.Sections', {
extend : 'Ext.data.Store',
config : {
autoLoad: true,
model: 'listdemo.model.Sections',
proxy:{
type : 'ajax',
url:'http://localhost/catt.php',
reader:{
type:'json',
rootProperty:'categories'
}
}
}
});
型号代码是-----
Ext.define('listdemo.model.Sections', {
extend: 'Ext.data.Model',
config: {
fields: ['categories_id', 'categories_name','subcategories'],
}
});
而观点是——
Ext.define('listdemo.view.Main',{
extend: 'Ext.NestedList',
xtype:'main',
requires: [
'Ext.TitleBar',
'Ext.dataview.List',
'Ext.data.Store',
'Ext.dataview.NestedList'
],
config:{
title: 'Categories',
//store:'Sections',
items:[
{
xtype:'list',
itemTpl:'{categories_name}',
title:'Categories',
store:'Sections',
}
]
}
});
我的php文件返回----
{"categories":[{"categories_id":"1","categories_name":"Hardware","subcategories":[{"categories_id":"4","categories_name":"显卡"},{"categories_id ":"5","categories_name":"Printers"},{"categories_id":"6","categories_name":"Monitors"},{"categories_id":"7","categories_name":"Speakers"} ,{"categories_id":"8","categories_name":"键盘"},{"categories_id":"9","categories_name":"鼠标"},{"categories_id":"16","categories_name": "内存"},{"categories_id":"17","categories_name":"CDROM 驱动器"}]},{"categories_id":"2","categories_name":"Software","subcategories":[{"categories_id":"18","categories_name":"模拟"},{"categories_id ":"19","categories_name":"Action"},{"categories_id":"20","categories_name":"策略"}]},{"categories_id":"3","categories_name":"DVD电影","子类别":[{"categories_id":"10","categories_name":"Action"},{"categories_id":"11","categories_name":"科幻小说"},{"categories_id": "12","categories_name":"喜剧"},{"categories_id":"13","categories_name":"卡通"},{"categories_id":"14","categories_name":"Thriller"},{"categories_id":"15","categories_name":"戏剧"}]}] }
我将如何在主要类别下显示子类别。