【发布时间】:2014-10-19 06:21:45
【问题描述】:
我不知道为什么我的数据不会从这里加载到我的 AccordionList 元素: https://github.com/kawanoshinobu/Ext.ux.AccordionList
我在这样的面板中创建它:
{
xtype: 'accordionlist',
store: Ext.create('Rks.store.Bcks'),
flex: 1
},
它调用一个定义如下的商店:
Ext.define('Rks.store.Bcks', {
extend: 'Ext.data.TreeStore',
requires: ['Rks.model.Bck'],
config: {
itemId: 'bks',
model: 'Rks.model.Bck',
defaultRootProperty: 'items',
proxy: {
type: 'ajax',
url: 'path/to/ajax',
},
autoLoad: false,
listeners:{
load: function( me, records, successful, operation, eOpts ){
console.log("data loaded", records);
}
}
}
});
当我调用包含手风琴的视图时,控制台会记录看起来不错的对象:
items: [{bck_id:3, author_id:1, title:test, items:[{c_id:2, bck_id:3, title:choice1, leaf:true}]}]
但是什么都没有出现。面板是空的,没有显示手风琴项。
但是,当我用内联 JSON 替换代理时,一切看起来都很好:
Ext.define('Rks.store.Bcks', {
extend: 'Ext.data.TreeStore',
requires: ['Rks.model.Bck'],
config: {
itemId: 'bks',
model: 'Rks.model.Bck',
defaultRootProperty: 'items',
root: {
items: [
{ bck_id: 1, author_id: 1, title: 'bck1', items: [ {c_id: 1, bck_id: 1, title: 'choice1', leaf: true} ] }
]
}
autoLoad: false,
listeners:{
load: function( me, records, successful, operation, eOpts ){
console.log("data loaded", records);
}
}
}
});
这里的项目显示在手风琴中。我无法弄清楚为什么第二个示例有效而第一个示例无效。在为 Accordion 调用商店代理时,我应该做些什么特别的事情吗?
更新:我已经设法让手风琴列表显示数据,但是当我更改商店的 url 并重新加载它时,商店重新加载但手风琴列表没有更新。手风琴列表继续显示它从第一个 URL 接收到的数据,而不是从带有修改的 URL 的重新加载中接收到的数据。
谢谢
【问题讨论】: