0
我正在使用一个没有代理的简单TreeStore来构建我的Menu。下面是一个简单的例子:ExtJS4:从Treestore传递参数/属性到控制器
商店:
Ext.define('LT.store.MnuApplication', {
extend: 'Ext.data.TreeStore',
root: {
expanded: true,
children: [{
text: "Lists",
expanded: true,
children: [{
text: "Countries",
leaf: true,
}]
}]
}
});
在控制器从来就增加了一个监听器 “点击” 事件:
控制器:
init: function() {
this.control({
/**
* Catch the treepanels in the menu accordion
*/
'menu-main treepanel': {
itemclick: function (view, record, item, index, event){
var clickedMnuNode = record;
var tabPanel = this.getTabPanel();
// Open tab only if the menu node is a leaf node
if (clickedMnuNode.isLeaf()) {
tabPanel.add({
xtype: clickedMnuNode.raw.loadTabComponent
}).show();
}
}
}
});
this.callParent();
}
现在我对这个解决方案的问题:我想在TreeStore中定义哪些操作应该由控制器完成 - 特别是应该加载哪个组件。
例如,我想的是,TreeStore看起来像这样:
Ext.define('LT.store.MnuApplication', {
extend: 'Ext.data.TreeStore',
root: {
expanded: true,
children: [{
text: "Lists",
expanded: true,
children: [{
text: "Countries",
leaf: true,
loadComponent: 'country-list',
loadTarget: 'tabPanel'
}]
}]
}
});
正如你所看到的从来就增加了两个新参数的树叶。现在我不能通过记录的“RAW”方法访问这些数据集。但那不是一个很好的解决方案 - 不是吗?
有没有人有我的想法,如何从我的TreeStore传递额外参数(如“loadComponent”或“loadTaget”)到控制器?
在此先感谢&欢呼声, 迈克尔
我有一个类似的问题,那么你将如何通过节点的指导到TreeStore代理,以便基于扩展节点加载下一级节点? – sambomartin 2012-02-16 16:44:05
你应该在你的模型中设置idProperty。代理将在请求时使用此属性。 – 2012-02-16 16:52:14
你是明星!真的很简单。谢谢 – sambomartin 2012-02-17 08:48:44