Model view controller ExtJS 4.0 MVC应用程序中的TreeStore出现问题
ExtJS的新版本会让你的chrome变得不稳定(或者是我的代码?)!让我解释一下我的情况 我正在研究extjs4.0的新MVC架构。我有一个树面板显示我的应用程序菜单或导航。根据架构,我尝试将树面板拆分为控制器、视图和单独的存储 以下是我的看法:Model view controller ExtJS 4.0 MVC应用程序中的TreeStore出现问题,model-view-controller,tree,extjs4,Model View Controller,Tree,Extjs4,ExtJS的新版本会让你的chrome变得不稳定(或者是我的代码?)!让我解释一下我的情况 我正在研究extjs4.0的新MVC架构。我有一个树面板显示我的应用程序菜单或导航。根据架构,我尝试将树面板拆分为控制器、视图和单独的存储 以下是我的看法: Ext.define('CRM.view.menu.View', { alias: 'widget.menutree', extend: 'Ext.tree.Panel', initComponent: function(
Ext.define('CRM.view.menu.View', {
alias: 'widget.menutree',
extend: 'Ext.tree.Panel',
initComponent: function() {
console.log('initComponent of View...');
Ext.apply(this, {
title: 'Simple Tree',
width: 200,
store: 'MainMenu',
rootVisible: false
});
this.callParent(arguments);
}
});
我的树的商店:
Ext.define('CRM.store.MainMenu', {
extend: 'Ext.data.TreeStore',
constructor: function() {
console.log('Constructor of MainMenu TreeStore');
config = Ext.apply(this,{
proxy: {
type: 'ajax',
url: 'data/menu.json'
},root: {
text: 'Menu',
id: 'src',
expanded: true
}
});
this.callParent(arguments);
}
});
在我的控制器中,我也提供了我的店铺信息。以下是我的控制器配置的一部分:
Ext.define('CRM.controller.MainMenu',{
extend: 'Ext.app.Controller',
stores: ['MainMenu'],
refs: [
{ref:'menu',selector: 'menutree'},
{ref:'cp',selector: 'centerpane'}
],
.
.
.
在初始执行时,我得到以下错误:
对象主菜单没有方法
“getRootNode”
但现在,我发现了更奇怪的错误:
请注意,chrome在树存储的构造函数中停止执行
同时,在firefox中:
Firefox执行得更好,但没有应用程序呈现
经过一些尝试和错误后。。我确实找到了让我的应用程序运行的方法。。这是为了避免使用我的店铺,直接提供店铺信息,如下所示:
Ext.define('CRM.view.menu.View', {
alias: 'widget.menutree',
extend: 'Ext.tree.Panel',
initComponent: function() {
console.log('initComponent of View...');
Ext.apply(this, {
title: 'Simple Tree',
width: 200,
store: {
proxy: {
type: 'ajax',
url: 'data/menu.json'
},root: {
text: 'Menu',
id: 'src',
expanded: true
}
},
rootVisible: false
});
this.callParent(arguments);
}
});
现在应用程序执行时没有任何问题
有人尝试过使用MVC架构创建树面板吗?我不知道如何解决这个问题 看来这是一个已知的问题!!!引述: “Ext.tree.Panel”的父类 在商店中查找商店 在“initComponent”方法中, 但是“Ext.tree.Panel”试图使用它 以前 所以,一种方法是将存储编码到树中,另一种方法是在initComponent方法中重新分配存储。代码如下:
initComponent: function(){
this.store = Ext.data.StoreManager.lookup(this.store);
this.callParent(arguments);
}