-
8 May 2011 3:28 AM #1
Trouble creating a tree!
Trouble creating a tree!
I am trying to load a tree in an MVC application. And I keep getting this error:
The tree works fine when I keep my data hard-coded and is directly loaded in to the tree object. Since, I am using MVC, I moved the store separately. like:Code:Object MainMenu has no method 'getRootNode'
And in my view I have:Code:Ext.define('CRM.store.MainMenu', { extend: 'Ext.data.TreeStore', initComponent: function() { Ext.apply(this,{ autoLoad: true, proxy: { type: 'ajax', url: 'data/menu.json' }, root: { text: 'Menu', id: 'src', expanded: true } }); this.callParent(arguments); } });
And, I have provided the store info to my controller as well: stores: ['MainMenu'],Code:Ext.apply(this, { title: 'Simple Tree', width: 200, store: 'MainMenu' });
What am I missing? Can somebody point out my mistake?
Thanks in advance,
-
8 May 2011 4:32 AM #2
a treestore has no initComponent method, use the constructor.
-
8 May 2011 4:50 AM #3
-
8 May 2011 4:57 AM #4
-
8 May 2011 9:05 AM #5
with and without the root config.. I get the same error!
with and without the root config.. I get the same error!
I tried with and without the root config and get the same error.. here is my code with the root config:
Code:Ext.define('CRM.store.MainMenu', { extend: 'Ext.data.TreeStore', constructor: function() { Ext.apply(this,{ proxy: { type: 'ajax', url: 'data/menu.json' }, root: { text: 'Menu', id: 'src', expanded: true } }); this.callParent(arguments); } });
-
8 May 2011 9:59 PM #6
this is a known problem. I have it myself. No solution yet, besides defining your data inside the tree.
-
8 May 2011 11:02 PM #7
medusadelft is right. The parent class of "Ext.tree.Panel" looks for the store in the store manager in the "initComponent" method, but "Ext.tree.Panel" tries to use it before.
There are two other solution.
If you let your controller create the TreePanel, you can set the store property to an object of your "CRM.store.MainMenu" class or you overwrite the "initComponent" method of your view and set your store manually:
Code:initComponent: function(){ this.store = Ext.data.StoreManager.lookup(this.store); this.callParent(arguments); }
-
8 May 2011 11:54 PM #8
-
10 May 2011 7:45 AM #9
I still have problems calling expandAll(), getting the error: this.store.getRootNode is not a function.
-
11 Jun 2012 6:49 AM #10
Hi
i have the same problem although I put
this.store = Ext.data.StoreManager.lookup(this.store);
Please help! Below is my mvc with tree panel
view.tree
StoreCode:HTML Code:Ext.define('Pandora.view.OrganisationTree', { extend: 'Ext.tree.Panel', alias: 'widget.organisationtree', requires: 'Pandora.store.Organisations', store: 'Organisations', initComponent: function () { this.store = Ext.data.StoreManager.lookup(this.store); Ext.apply(this, { title: 'Roles & Fournisseurs', width: 150, height: 300, region: 'west', floatable: false, root:'' }); this.callParent(); }});
ModelCode:Ext.define('Pandora.store.Organisations', { extend: 'Ext.data.Store', model: 'Pandora.model.Organisation', requires: 'Pandora.model.Organisation', //autoLoad: true, root: { expanded: true, children:[{text: "Draft", id: 'draft',expanded: false, clsicon: 'icon-reply'}, { text: "All roles and bidders", id: 'all', expanded: true, children: [ { text: "Local roles", id: 'all_roles',expanded: true, children: [ { text: "Buyer", id : 'buyer', expanded: true, children: [ { text: "dfsqdqsdqs", leaf: true }, { text: "Buyer name", leaf: true } ] }, { text: "Engineer", id : 'engineer', expanded: true, children: [ { text: "sfdsfsdfs", leaf: true }, { text: "Engineer name", leaf: true } ] } ] }, { text: "Bidders", id: 'bidder', expanded: true, children: [ { text: "fsdfdsfds", id: 'subsea', expanded: true, children: [ { text: "[Main] Bidder name 1", leaf: true }, { text: "Bidder name 2", leaf: true } ] }, { text: "fdsfdsfsdfds", id : 'van', expanded: false, children: [ { text: "[Main] Bidder name 3", leaf: true }, { text: "Bidder name 4", leaf: true } ] } ] } ] }] }, proxy: { type: 'memory', reader: { type: 'json' } } });
ControllerCode:Ext.define('Pandora.model.Organisation', { extend: 'Ext.data.Model', fields: ['id', 'text'] });
app.jsCode:Ext.define('Pandora.controller.Organisation', { extend: 'Ext.app.Controller', refs: [{ ref: 'organisationTree', selector: 'organisationtree' }], stores: ['Organisations'/*, 'SearchResults'*/], onLaunch: function () { var organisationStore = Ext.create('Pandora.store.Organisations'); var view = Ext.create('Pandora.view.OrganisationTree'); view.bindStore(store); } });
Code:Ext.Loader.setConfig({ enabled:true }); Ext.application({ name: 'Pandora', models: ['Organisation'], stores: ['Organisations'], controllers: ['Organisation'], launch: function () { var x = Ext.create('Pandora.view.Viewport'); } });
Similar Threads
-
[Solved] Trouble creating a simple div of a parent
By borg in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 17 Apr 2009, 4:57 AM -
Tree View JSON Trouble
By gtfMasterJohn in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 17 Sep 2008, 7:12 AM -
Having trouble creating single instance of pre-defined GridPanel for application
By joku in forum Ext 2.x: Help & DiscussionReplies: 9Last Post: 18 Apr 2008, 3:27 PM -
creating tree based on other tree's nodes?
By bajoran in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 17 Nov 2007, 5:43 AM -
mixing tree and menu into a hybrid - having trouble
By Stoob in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 31 Oct 2007, 11:00 PM


Reply With Quote
