Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-5248 in a recent build.
  1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    102
    Vote Rating
    6
    campersau1 is on a distinguished road

      0  

    Default Ext 4.1 Beta 2 Ext.data.TreeStore setting the root property in the proxy doesn't work

    Ext 4.1 Beta 2 Ext.data.TreeStore setting the root property in the proxy doesn't work


    Hi,

    in Ext 4.0.7 this example worked:

    Code:
    var store = Ext.create('Ext.data.TreeStore', {
        root: {
            expanded: true,
            CHILDREN: [
                { text: "detention", leaf: true },
                { text: "homework", expanded: true, CHILDREN: [
                    { text: "book report", leaf: true },
                    { text: "alegrbra", leaf: true}
                ] },
                { text: "buy lottery tickets", leaf: true }
            ]
        },
        proxy: {
            type: "memory",
            reader: {
                type: "json",
                root: "CHILDREN" // <- this does not work! it shows an empty tree
            }
        }
    });
    
    
    Ext.create('Ext.tree.Panel', {
        title: 'Simple Tree',
        width: 200,
        height: 150,
        store: store,
        rootVisible: false,
        renderTo: Ext.getBody()
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    899
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thank you for the report.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jun 2009
    Posts
    102
    Vote Rating
    6
    campersau1 is on a distinguished road

      0  

    Default


    The way I fixed it was to add the "CHILDREN" field to the fields property:

    Code:
    var store = Ext.create('Ext.data.TreeStore', {
        fields: ["text","CHILDREN"], // <- workaround
        
        root: {
            expanded: true,
            CHILDREN: [
                { text: "detention", leaf: true },
                { text: "homework", expanded: true, CHILDREN: [
                    { text: "book report", leaf: true },
                    { text: "alegrbra", leaf: true}
                ] },
                { text: "buy lottery tickets", leaf: true }
            ]
        },
        defaultRootProperty: "CHILDREN", // <- this does not work! it shows an empty tree
        proxy: {
            type: "memory",
            reader: {
                type: "json",
                root: "CHILDREN" // <- this does not work! it shows an empty tree
            }
        }
    });
    
    
    
    
    Ext.create('Ext.tree.Panel', {
        title: 'Simple Tree',
        width: 200,
        height: 150,
        store: store,
        rootVisible: false,
        renderTo: Ext.getBody()
    });

Thread Participants: 1