同步加载"MyApp.store.TreeStructures";考虑在Ext.onReady上方添加Ext.require('MyApp.store.TreeStructures') [英] Synchronously loading 'MyApp.store.TreeStructures'; consider adding Ext.require('MyApp.store.TreeStructures') above Ext.onReady

查看:106
本文介绍了同步加载"MyApp.store.TreeStructures";考虑在Ext.onReady上方添加Ext.require('MyApp.store.TreeStructures')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面,您将看到我在Sencha ExtJS MVC应用程序中创建的MVC视图中遇到了JavaScript异常.我有另一个MVC视图,扩展了"Ext.tree.Panel",该视图读取一个简单的JSON对象,而不是通过Ext.Direct代理和.NET服务器端堆栈提取数据,但是唯一不同的是代理实现和当然是我们的MVC控制器逻辑.在静态(JSON)实现中,我们的代理在模型中定义.在动态(Ext.Direct)实现中,我们的代理在商店中定义.在浏览器崩溃之前,TreeStructures.js(存储)JavaScript文件会不断被请求无数次.请参阅下面的例外情况.

Below, you will see that I'm getting a JavaScript exception with an MVC view I created in an Sencha ExtJS MVC application. I have another MVC view that extends 'Ext.tree.Panel' that reads a simple JSON object instead of pulling the data via an Ext.Direct proxy and .NET server-side stack, but the only thing that's different is the proxy implementation and of course our MVC controller logic. In the static (JSON) implementation, our proxy is defined in the model. In the dynamic (Ext.Direct) implementation, our proxy is defined in the store. The TreeStructures.js (store) JavaScript file keeps being requested an infinite amount of times until the browser crashes. See below for that exception.

我非常怀疑这是一个Ext.Direct问题,因为我还有其他商店在这种架构下工作得很好.我看到[Ext.Loader]异常,但是我不确定为什么每个新的TreeStructures.js请求都会重复这种情况.或在哪里实现这一要求.我的理解是app.js定义了控制器.然后,控制器将模型定义为商店.然后,视口定义并实例化其他MVC视图.我的其他视图"是树视图.然后视图实现商店.

I highly doubt this is an Ext.Direct issue because I have other stores working great with this architecture. I see the [Ext.Loader] exception, but I'm not sure why that one keeps repeating with every new TreeStructures.js request. Or where to implement that requires. My understanding is that the app.js defines the controllers. The controller then defines the models an stores. And the Viewport defines and instantiates other MVC views. My "other views" being the tree views. And the view implements the store.

此外,Sencha Cmd"sencha应用程序构建"命令不起作用.通常,我的应用程序编译时不会出现任何问题,因此在存储或MVC配置中肯定缺少此动态树所必需的东西.

Also, the Sencha Cmd "sencha app build" command is not working. Normally my application compiles without any issues, so something is definitely missing in the store or MVC configuration that's necessary for this dynamic tree.

[Ext.Loader] Synchronously loading 'MyApp.store.TreeStructures'; consider adding Ext.require('MyApp.store.TreeStructures') above Ext.onReady

浏览器因以下JavaScript异常而崩溃:

注意:在浏览器崩溃之前,TreeStructures.js(存储)JavaScript文件会不断被请求无数次:

Browser crashes with this JavaScript Exception:

Note: The TreeStructures.js (store) JavaScript file keeps being requested an infinite amount of times until the browser crashes with this:

Uncaught RangeError: Maximum call stack size exceeded

Sencha Cmd错误(调用"sencha app build"命令后):

[ERR] failed to find meta class definition for name MyApp.store.TreeStructures
[ERR] def was null
[ERR] C2008: Requirement had no matching files <MyApp.store.TreeStructures> -- unknown-file:-1

静态树实现(读取JSON对象以获取数据):

Ext.define('MyApp.store.Categories', {
    extend : 'Ext.data.TreeStore',
    model : 'MyApp.model.Category',
    autoLoad : true,
    root : {
        text : 'All',
        alias : '',
        expanded : true
    }
});

Ext.define('MyApp.model.Category', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'alias', type: 'auto' },
        { name: 'text', type: 'auto' }
    ],

    proxy: {
        type: 'ajax',
        url: 'data/categories.json'
    }
});

Ext.define('MyApp.controller.ConceptTreeReadonly', {
    extend : 'Ext.app.Controller',
    stores: ['Categories'],
    models: ['Category'],
    refs : [{
        ref: 'categories',
        selector: 'view-west'
    }],
});

动态树实现(使用服务器端堆栈获取数据):

Ext.create('MyApp.store.TreeStructures', {
    extend: 'Ext.data.TreeStore',
    model : 'MyApp.model.TreeStructure',
    proxy: {
        type: 'direct',
        directFn: Concept_Tree_Structure.read,
        reader: {
            root: 'data'
        }
    },
    root: {
        text: 'Concept Tree',
        id: 'root',
        expanded: false
        //children: []
    },
    autoLoad: false
});

Ext.define('MyApp.model.TreeStructure', {
    extend: 'Ext.data.Model',
    xtype: 'model-tree-structure',

    fields: [
        { name: 'text' }, //  string                    
        { name: 'id' }, // Int32    type: 'int'
        { name: 'expanded' }, // boolean                   
        { name: 'leaf' }, // boolean       
        { name: 'children' } // List<TreeStructure>            
    ]
});

Ext.define('MyApp.controller.ConceptTreeController', {
    extend : 'Ext.app.Controller',

    stores: ['TreeStructures', 'Concepts'],
    models: ['TreeStructure', 'Concept'],

    refs : [{
        ref: 'concept-tree',
        selector: 'view-concept-tree'
    }],
    init : function() {

        this.getConceptsStore().load({
            params: {
                start: 0, 
                limit: 10,
                foo: 'bar'
            }
        });

        this.getTreeStructuresStore().load({
            params: {
                start: 0,
                limit: 10,
                foo: 'bar'
            }
        });
    }
});

推荐答案

更改Ext.create('MyApp.store.TreeStructures'...

Change Ext.create('MyApp.store.TreeStructures'...

到Ext.define('MyApp.store.TreeStructures'...

To Ext.define('MyApp.store.TreeStructures'...

这篇关于同步加载"MyApp.store.TreeStructures";考虑在Ext.onReady上方添加Ext.require('MyApp.store.TreeStructures')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆