如何在extjs 4的存储中指定型号名称? [英] How to specify model name in store of an extjs 4?

查看:110
本文介绍了如何在extjs 4的存储中指定型号名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用extjs 4的商店和模型时,我感到沮丧.即使我在商店内指定了模型名称,也遇到了 Store defined with no model. You may have mistyped the model name.错误.

这是我的代码:

 Ext.define('iWork.store.CandidateDistribution', {
    extend: 'Ext.data.TreeStore',
    autoLoad: true,
    requires: 'iWork.model.Location',
    model: 'iWork.model.Location',

    proxy: {
        type: 'ajax',
        url: 'data/CandidateDistribution/CandidateCount.json',
        reader: {
            type: 'pentahoReader',
            root: 'resultset'
        }
    },
    listeners: {
        load: function(treeStore, currentNode, records, success, options) {
            console.log('in load listener');
            console.log(records);
        },
        beforeappend: function(currentNode, newNode, options) {
            console.log('in beforeAppend listener');

        },
        add: function(store, records, options) {
            console.log('in add listener');
        },
        beforeinsert: function(currentNode, newNode, option) {
            console.log('in beforeInsert listener');
        }
    }
});
 

我尝试将model: 'iWork.model.Location',更改为model: 'Location'model: "Location"model: "iWork.model.Location",但仍然无法正常工作.

模型文件中的代码如下:

 Ext.define('iWork.model.Location', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'name', type: 'string'},
        {name: 'candidateCount', type: 'string'}
    ]
});
 

和引用此商店的treepanel代码如下:

 Ext.define('iWork.view.CandidateDistribution', {
    extend: 'Ext.window.Window',
    alias: 'widget.candidateDistribution',
    require: ['iWork.store.CandidateDistribution'],
    layout: {
        type: 'hbox',
        align: 'stretch'
    },
    autoShow: true,

    initComponent: function() {
        this.items = [
            {
                xtype: 'treepanel',
                title: 'Location wise customer Distribution',
                store: 'iWork.store.CandidateDistribution',
                width: '25%',
                height: '100%',
                rootVisible: false
            }
        ];
        this.callParent(arguments);
    }
});
 

我试图将store: 'iWork.store.CandidateDistribution'更改为store: 'CandidateDistribution',但随后也无法正常工作.

如果将store: 'iWork.store.CandidateDistribution'更改为store: CandidateDistribution,则会在ext-debug.js (line 8002)

中收到以下错误

me.store is undefined
[Break On This Error] }, 

我找不到我犯错的地方.如果我错过任何其他配置或做错了什么,请告诉我.

谢谢!!


我的应用程序的index.html文件如下所示:

 <html>
    <head>
        <title>iWork Dashboards</title>
        <link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css" />
        <script type="text/javascript" src="../extjs/ext-debug.js"></script>
    <script type="text/javascript" src="app/app.js"></script>
    <script type="text/javascript" src="app/PentahoReader.js"></script>
    </head>
    <body>
    </body>
</html>
 


解决方案

这是NodeStore中的一个错误,由Ext.tree.View使用.使用树形面板"时,您将始终看到这一点.

如果在生成警告的行上中断,并查看堆栈,您会看到它位于AbstractStore的构造函数中,而NodeStore的构造函数已调用该构造函数,而TreeView的initComponent则调用了该构造函数. /p>

I am getting frustrated while working with store and model of extjs 4. I am getting Store defined with no model. You may have mistyped the model name. error even though I have specified model name inside store.

Here is my code :

Ext.define('iWork.store.CandidateDistribution', {
    extend: 'Ext.data.TreeStore',
    autoLoad: true,
    requires: 'iWork.model.Location',
    model: 'iWork.model.Location',

    proxy: {
        type: 'ajax',
        url: 'data/CandidateDistribution/CandidateCount.json',
        reader: {
            type: 'pentahoReader',
            root: 'resultset'
        }
    },
    listeners: {
        load: function(treeStore, currentNode, records, success, options) {
            console.log('in load listener');
            console.log(records);
        },
        beforeappend: function(currentNode, newNode, options) {
            console.log('in beforeAppend listener');

        },
        add: function(store, records, options) {
            console.log('in add listener');
        },
        beforeinsert: function(currentNode, newNode, option) {
            console.log('in beforeInsert listener');
        }
    }
});

I tried changing model: 'iWork.model.Location', to model: 'Location', model: "Location", and to model: "iWork.model.Location" but still its not working.

Code in model file is as follows:

Ext.define('iWork.model.Location', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'name', type: 'string'},
        {name: 'candidateCount', type: 'string'}
    ]
});

and treepanel code which references this store is as follows :

Ext.define('iWork.view.CandidateDistribution', {
    extend: 'Ext.window.Window',
    alias: 'widget.candidateDistribution',
    require: ['iWork.store.CandidateDistribution'],
    layout: {
        type: 'hbox',
        align: 'stretch'
    },
    autoShow: true,

    initComponent: function() {
        this.items = [
            {
                xtype: 'treepanel',
                title: 'Location wise customer Distribution',
                store: 'iWork.store.CandidateDistribution',
                width: '25%',
                height: '100%',
                rootVisible: false
            }
        ];
        this.callParent(arguments);
    }
});

I have tried to change store: 'iWork.store.CandidateDistribution' to store: 'CandidateDistribution' but then also its not working.

If I change store: 'iWork.store.CandidateDistribution' to store: CandidateDistribution, I get following error in ext-debug.js (line 8002)

me.store is undefined
[Break On This Error] }, 

I am not able to find where have I made mistake. Please let me know if I have missed any other configuration or what I have done wrong.

Thanks !!


EDIT 1 : index.html file of my app looks as follows :

<html>
    <head>
        <title>iWork Dashboards</title>
        <link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css" />
        <script type="text/javascript" src="../extjs/ext-debug.js"></script>
    <script type="text/javascript" src="app/app.js"></script>
    <script type="text/javascript" src="app/PentahoReader.js"></script>
    </head>
    <body>
    </body>
</html>


解决方案

This is a bug in NodeStore, which is used by Ext.tree.View. You will always see this when you use a Tree Panel.

If you break on the line that generates the warning, and look at the stack, you'll see that it's in the AbstractStore's constructor which has been called by the NodeStore's constructor, which in turn is called by Tree View's initComponent.

这篇关于如何在extjs 4的存储中指定型号名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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