1. #1
    Sencha User
    Join Date
    Jul 2007
    Posts
    50
    Vote Rating
    0
    olakara is on a distinguished road

      0  

    Default 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:
    Code:
    Object MainMenu has no method 'getRootNode'
    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:
     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 in my view I have:
    Code:
    Ext.apply(this, {
    	title: 'Simple Tree',						
    	width: 200,				
    	store: 'MainMenu'
    });
    And, I have provided the store info to my controller as well: stores: ['MainMenu'],

    What am I missing? Can somebody point out my mistake?
    Thanks in advance,
    Thanks and Regards,
    Abdel Olakara.
    [ blog : http://technopaper.blogspot.com ]

  2. #2
    Sencha User
    Join Date
    Apr 2010
    Location
    Berlin
    Posts
    19
    Vote Rating
    0
    vollchraZ is on a distinguished road

      0  

    Default


    a treestore has no initComponent method, use the constructor.

  3. #3
    Sencha User
    Join Date
    Jul 2007
    Posts
    50
    Vote Rating
    0
    olakara is on a distinguished road

      0  

    Default


    Quote Originally Posted by vollchraZ View Post
    a treestore has no initComponent method, use the constructor.
    I did try with constructor and still having the same result! Here is my updated code:
    Code:
    constructor: function() {
    	
    		Ext.apply(this,{
    			proxy: {
    				type: 'ajax',
    				url: 'data/menu.json'
    			}
    		});
    		
    		this.callParent(arguments);
    	}
    Thanks and Regards,
    Abdel Olakara.
    [ blog : http://technopaper.blogspot.com ]

  4. #4
    Sencha User
    Join Date
    Apr 2010
    Location
    Berlin
    Posts
    19
    Vote Rating
    0
    vollchraZ is on a distinguished road

      0  

    Default


    where is your root config?

  5. #5
    Sencha User
    Join Date
    Jul 2007
    Posts
    50
    Vote Rating
    0
    olakara is on a distinguished road

      0  

    Default with and without the root config.. I get the same error!

    with and without the root config.. I get the same error!


    Quote Originally Posted by vollchraZ View Post
    where is your root config?
    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);
    	}
    });
    Thanks and Regards,
    Abdel Olakara.
    [ blog : http://technopaper.blogspot.com ]

  6. #6
    Sencha User
    Join Date
    Apr 2007
    Posts
    172
    Vote Rating
    1
    medusadelft is on a distinguished road

      0  

    Default


    this is a known problem. I have it myself. No solution yet, besides defining your data inside the tree.

  7. #7
    Sencha User
    Join Date
    Apr 2010
    Location
    Berlin
    Posts
    19
    Vote Rating
    0
    vollchraZ is on a distinguished road

      0  

    Default


    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. #8
    Sencha User
    Join Date
    Jul 2007
    Posts
    50
    Vote Rating
    0
    olakara is on a distinguished road

      0  

    Smile


    Quote Originally Posted by vollchraZ View Post
    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);
    }
    @vollchraZ, thanks for the solution. I went with the above code in my view and the application is working fine.
    Thanks and Regards,
    Abdel Olakara.
    [ blog : http://technopaper.blogspot.com ]

  9. #9
    Sencha User
    Join Date
    Apr 2007
    Posts
    172
    Vote Rating
    1
    medusadelft is on a distinguished road

      0  

    Default


    I still have problems calling expandAll(), getting the error: this.store.getRootNode is not a function.

  10. #10
    Sencha User
    Join Date
    Mar 2012
    Posts
    211
    Vote Rating
    0
    hieu79vn is an unknown quantity at this point

      0  

    Default


    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


    Code:
    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();    }});
    Store


    Code:
    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'
                }
            }
    
    
    });
    Model
    Code:
    Ext.define('Pandora.model.Organisation', {
        extend: 'Ext.data.Model',
        fields: ['id', 'text']
    });
    Controller


    Code:
    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);
        }
       
    });
    app.js
    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

  1. [Solved] Trouble creating a simple div of a parent
    By borg in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 17 Apr 2009, 4:57 AM
  2. Tree View JSON Trouble
    By gtfMasterJohn in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 17 Sep 2008, 7:12 AM
  3. Replies: 9
    Last Post: 18 Apr 2008, 3:27 PM
  4. creating tree based on other tree's nodes?
    By bajoran in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 17 Nov 2007, 5:43 AM
  5. mixing tree and menu into a hybrid - having trouble
    By Stoob in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 31 Oct 2007, 11:00 PM

Thread Participants: 4

Tags for this Thread