2

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>

Darin Kolev
  • 3,401
  • 13
  • 31
  • 46
Shekhar
  • 11,438
  • 36
  • 130
  • 186
  • 1
    Is the model file loaded properly? – Molecular Man Feb 15 '12 at 12:50
  • How to check whether model file is loaded or not? – Shekhar Feb 15 '12 at 12:56
  • The corresponding script has to be present in the `` of your html. You can check it via the firebug or the google chrome's development tools. You have to check it only if you keep the model and the store in separate files. – Molecular Man Feb 15 '12 at 13:16
  • @MoleculeMan, I have added contents of index.html file in question itself. – Shekhar Feb 15 '12 at 13:23
  • 1
    It seems like you have posted your initial(static) html code. There is nothing interesting in it. You should post rendered code. Take it from firebug's html tab after the page is loaded. – Molecular Man Feb 15 '12 at 13:34
  • @MoleculeMan, you are right. Location.js file which contains model information of Location is not getting loaded. I have kept model files in 'app/model' folder and store files in 'app/store' folder. – Shekhar Feb 15 '12 at 13:42

1 Answers1

4

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.

David Kanarek
  • 12,611
  • 5
  • 45
  • 62
  • Ya.. I saw stack trace and the exact line where this error occurs. I would like to know how to overcome this problem? – Shekhar Feb 15 '12 at 15:09
  • It's only a warning so I wouldn't worry too much. I don't think you can fix it without patching Ext. If they don't have a bug report on it yet, you could submit one. You might also check out 4.1b2 and see if that's fixed it. – David Kanarek Feb 15 '12 at 15:14