Hi,
I got error - Cannot call method 'getRootNode' of undefined - with my extjs mvc tree. The code is as follows:
TreeController.js
Ext.define(
'Am.example.controller.TreeController', {
extend:
'Ext.app.Controller',stores: ['TreeStore'],models: ['TreeModel'],views: ['user.Tree']
});
TreeModel.js
Ext.define('Am.example.model.TreeModel', {
extend:
'Ext.data.Model',fields: [{ name: 'name', type: 'string' }]
});
TreeStore.js
Ext.define('Am.example.store.TreeStore', {
extend:
'Ext.data.TreeStore',requires: [ 'Am.example.model.TreeModel' ],model: 'Am.example.model.TreeModel',autoLoad: true,proxy: {type: 'ajax',api: {read: 'Am/example/data/tree.json'
},reader: {type: 'json',root: 'children',successProperty: 'success'}}
});
Tree.js
Ext.define('Am.example.view.user.Tree' ,{
extend:
'Ext.tree.Panel',alias: 'widget.usertree',title: 'Notes',rootVisible: false,store: 'TreeStore'
});
tree.json
{"success": true,"childNodes": [{ "id": 1, "name": "Phil", "leaf": true },{ "id": 2, "name": "Nico", "expanded": true, "children": [{ "id": 3, "name": "Mitchell", "leaf": true }]},{ "id": 4, "name": "Sue", "loaded": true }]
}
Does anyone know what is wrong? Any help is appreciated.
Thanks & regards,
nsfl