Results 1 to 3 of 3

Thread: Tree json model no load.

  1. #1

    Default Answered: Tree json model no load.


    I'm trying to load nested data in a hasmany, for create a tree. But the folder no expanded children.
    Store:

    Code:
    Ext.define('Myapp.store.Tree', {
        extend: 'Ext.data.TreeStore',
        alias: 'store.Tree',
        model: 'Myapp.model.Interface',
        storeId: 'storeInterfacesId',
        autoLoad : true,
     expanded: true, 
           proxy: {
                    type: 'ajax',
                    url: "data1.json",
                   reader : { type : 'json', rootProperty: 'Interfaces'}},
            });
    Model Interface
    Code:
    Ext.define(Myapp.model.Interface', {
            extend: 'Ext.data.Model',        
            config: {
                fields: [
                                    
                    { name: 'id',        type:'string' },
                    { name: 'description',    type:'string'},
                    { name: 'devices',reference: 'Device'}
                    
                ],
                hasMany: 
                {
                        model: 'Myapp.model.Device',
                        name: 'devices',
                        autoload: true,
                        useNull: true
                    },    
            }
        });
    Modelo Device
    Code:
    Ext.define('Myapp.model.Device', {
            extend: 'Ext.data.Model',
            config: {
                fields: [
                    { name: 'id',                        type:'string' },
                    { name: 'description',                type:'string' },
                    { name: 'address',                    type:'string' }
                    ],
            }
        });
    Json local
    Code:
    {"Interfaces":[{
        "id": "0",
        "description": "Interface virtual",
        "devices": [{
            "id": "0-0",
            "description": "Controlador virtual",
            "address": 247,
            
            }]
    
    
    }]}
    In my store I call the store by storeid:
    ......
    xtype: 'treepanel',
    scrollable:true,
    store: 'storeInterfacesId'

    columns: [{
    xtype: 'treecolumn',
    dataIndex:'description',
    align: 'left',
    sortable: true,
    }
    ],
    .....
    .....
    ...


  2. You have to extend TreeModel not the simple model. Anyway, just check the examples in Treepanel documentation page.

  3. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    Thanks for the report. Can you please post a runnable test case which exhibits the behavior you're seeing?
    https://fiddle.sencha.com/#view/editor

  4. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    908
    Answers
    105

    Default

    You have to extend TreeModel not the simple model. Anyway, just check the examples in Treepanel documentation page.

Similar Threads

  1. Load model with JSon params
    By Cp_Barbossa in forum Ext: Q&A
    Replies: 1
    Last Post: 26 Sep 2012, 8:37 AM
  2. Replies: 6
    Last Post: 15 Sep 2012, 4:34 AM
  3. Load JSON data into model using store
    By Ritesh.Chopade in forum Sencha Touch 2.x: Q&A
    Replies: 5
    Last Post: 3 Jun 2012, 1:26 PM
  4. Replies: 2
    Last Post: 15 Nov 2010, 10:47 AM

Posting Permissions

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