Results 1 to 8 of 8

Thread: Extjs tree error: Cannot call method 'getRootNode' of undefined

  1. #1
    Sencha User
    Join Date
    Jan 2014
    Posts
    4

    Default Extjs tree error: Cannot call method 'getRootNode' of undefined

    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

  2. #2
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6

    Default

    what happens on Browser-Concole if you execute:

    PHP Code:

    var test Ext.widget('usertree', {

    }).
    load().on('load', function(){

    console.log('successfuly loaded ...');
    }) 

  3. #3
    Sencha Premium User
    Join Date
    Jul 2013
    Posts
    24

    Default

    You need to set "rootVisible" = false in the TreeGridView configuration.


    PHP Code:
    viewConfig: { 
    rootVisiblefalse 
    }, 

  4. #4
    Sencha User
    Join Date
    Jan 2014
    Posts
    4

    Default

    I got same error with code provided by Malte123
    TypeError: Cannot call method 'getRootNode' of undefined

  5. #5
    Sencha User
    Join Date
    Jan 2014
    Posts
    4

    Default

    I use Ext.tree.Panel and have set rootVisible: false.



  6. #6
    Sencha Premium User
    Join Date
    Jul 2013
    Posts
    24

    Default

    every node must be called "children" you have the first one called "childNodes", they all have to be "children".


    {"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 }]}

    {"success": true,"children": [{ "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 }]}

  7. #7
    Sencha User
    Join Date
    Jan 2014
    Posts
    4

    Default

    Quote Originally Posted by Jarrod Roberson View Post
    every node must be called "children" you have the first one called "childNodes", they all have to be "children".


    {"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 }]}

    {"success": true,"children": [{ "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 }]}
    Thanks. I have changed "childNodes" to "children", and I still got the same error.

  8. #8
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6

    Default

    ask me again next days (by PM) ... I am waiting for Sencha Inc. fix my Vote-Rating back to 60.... (so please give me a reminder)

    (Someone votes all my Posts down... Support-Member "event" promised it will be fixed after weekend)

    I am angry about this so I wi1l not help before this is done. But give me a reminder when you see my Vote on 60+


    PS: For me seeing vote goes up is motivation enough trying to be helpful...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •