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