Results 1 to 2 of 2

Thread: How to set as root node in Ext.tree.TreePanel dynamically data with JSON type

  1. #1

    Default How to set as root node in Ext.tree.TreePanel dynamically data with JSON type

    Hi, all!
    I wanna do lazyLoading Tree and my server return the following json-data structure:
    Code:
    {"success": true, "results": [{"text" : "Audi", "id" : 100}, {"text": "BMW", "id": 101}]}
    There is TreeLoader:

    Code:
                var treeLoader = new Ext.tree.TreeLoader({
                    url: GO.url('packets/packet/json'),
                    requestMethod: 'GET',
                    preloadChildren: true
                });

    And TreePanel:
    Code:
                var tree = new Ext.tree.TreePanel({
                    useArrows: true,
                    autoScroll: true,
                    animate: true,
                    enableDD: false,
                    containerScroll: true,
                    rootVisible: false,
                    border: false,
    
    
                    loader: treeLoader,
    
    
                    root: {
                        nodeType: 'async',
                        text: 'Ext JS',
                        draggable: false,
                        id: 'src',
                        children: ??????
                    }
                });

    Question:
    How to specify in the TreePanel that its rootNode is "results" element in json?

  2. #2
    Sencha - Engineering israelroldan's Avatar
    Join Date
    Nov 2011
    Location
    The Netherlands
    Posts
    395

    Default

    This is not possible on 3.x. You'll need to create your own JsonLoader implementation that has a custom processResponse method to read your custom JSON structure.
    Israel Roldán | Senior Software Engineer (Framework tools)

  3. #3

Tags for this Thread

Posting Permissions

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