1. #1
    Ext User
    Join Date
    Apr 2009
    Posts
    6
    Vote Rating
    0
    hcortez is on a distinguished road

      0  

    Default Help, problem with TreePanel..

    Help, problem with TreePanel..


    Hi, I have the following code ...
    Code:
    Ext.onReady(function(){       
        var datosJSON = [
            {"text":"A","id":10,"leaf":false,"children":[
                {"text":"B","id":11,"leaf":false},            
                {"text":"C","id":18,"leaf":false,"children":[
                    {"text":"D","id":19,"leaf":false,"children":[
                        {"text":"E","id":191,"leaf":true},
                        {"text":"F","id":191,"leaf":true}
                    ]},
                    {"text":"G","id":20,"leaf":false},
                    {"text":"H","id":21,"leaf":false}
                ]}
            ]}
        ];
        
        var Tree = Ext.tree;
    
        
        var tree = new Tree.TreePanel('tree', {
            animate:true,
            enableDD:false,
            loader: new Tree.TreeLoader(),// no need a url, but here is the problem
            lines: true,
            selModel: new Ext.tree.MultiSelectionModel(),
            containerScroll: false
        });
        root = new Ext.tree.AsyncTreeNode({
            text: 'Autos',        
            id:'source',
            children: datosJSON
        });
        tree.setRootNode(root);
        root.expand();
    }
    ...my goal is to upload the data treePanel with JSON data type, but does not issue an error to put the TreeLoader () blank, someone can help me?

  2. #2

  3. #3
    Ext User
    Join Date
    Apr 2009
    Posts
    6
    Vote Rating
    0
    hcortez is on a distinguished road

      0  

    Default Please

    Please


    Sorry, but you could tell me if what I'm doing this right or not, or could give me a track to find the help because I can not find any solution...

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    API document. Read it. Compare to your code.

  5. #5
    Ext User
    Join Date
    Apr 2009
    Posts
    6
    Vote Rating
    0
    hcortez is on a distinguished road

      0  

    Default Success

    Success


    I succeed, I do not know if will be the best way but it works for me...
    Code:
    Ext.onReady(function(){       
        var datosJSON = [
            {"text":"A","id":10,"leaf":false,"children":[
                {"text":"B","id":11,"leaf":false},
                {"text":"C","id":12,"leaf":false},
                {"text":"D","id":18,"leaf":false,"children":[
                    {"text":"E","id":19,"leaf":false,"children":[
                        {"text":"F","id":191,"leaf":true},
                        {"text":"G","id":191,"leaf":true}
                    ]},
                    {"text":"H","id":20,"leaf":false}
                ]}
            ]}
        ];
        
        
        var root = new Ext.tree.TreeNode({
            expanded:true,
            text:'',
            draggable:false,
            id:'source',
            cls:"folder",
            children:datosJSON
        });
        
        new Ext.tree.TreeLoader({preloadChildren: true}).doPreload(root);
            
        var Tree = Ext.tree;
        
        var tree = new Tree.TreePanel({
            id:'tree_id',
            useArrows:true,
            animate:true,
            enableDD:true,
            autoScroll:true,
            border:false,
            rootVisible:false,
            root:root
    });
    });
    thks for all

Thread Participants: 1