Results 1 to 10 of 16

Thread: nested data in grid

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    48

    Default Answered: nested data in grid

    hello.
    i have problem with my grid.
    my json is nested data.
    i have no idea about displaying this data to my my grid panel
    please help me

    <CODE>:
    my json.

    {
    "success":"true",
    d:[{
    "idx":"1",
    "title":"DMC Name1",
    "state":"0",
    "regdate":"2012.10.10"
    },
    {
    "idx":"2",
    "title":"DMC Name2",
    "state":"0",
    "regdate":"2012.10.10"
    },
    {
    "idx":"3",
    "title":"DMC Name3",
    "state":"0",
    "regdate":"2012.10.10"
    }]
    }

    store
    var project_List = Ext.create('Ext.data.Store', {
    model: 'projectList',
    autoLoad:true,
    proxy:{
    type: 'ajax',
    url:'resource/json/projectlist.json',
    reader:{
    type:'json',
    }
    },
    listeners:{

    load:function(data){
    console.log(data);
    }
    }
    });
    my grid

    var list_Grid = Ext.create('Ext.grid.Panel',{
    store:project_List,
    id:'projectListGrid',
    columns:[
    {
    header:'Title',
    width:100,
    sortable:true,
    dataIndex:'success'
    },
    {
    header:'Regdate',
    sortable:true,
    dataIndex:'regdate'
    },
    {
    header:'Select',
    sortable:true,
    dataIndex:'string',
    text:'select'
    }
    ]

    });

    </CODE>
    i can display 'success' in my grid .

    list_capture.PNG


    my grid show 'true'
    but 'regdata' and other things can't.

    please help me.

  2. If so, I suggest you use Ext.Ajax.request() to load the json data, no need to use a store to load this. On returning of request, you decode the json data, check the "success" property and do the right thing.
    Code:
    Ext.Ajax.request({
       url: 'resource/json/projectlist.json',
       success: function(response){
            var data = Ext.decode(response.responseText);
            if(data.success == 'true'){
                // load data to grid store
                gridStore.loadData(data.d);
            } else {
                // handle the success == 'false'
            }
       },
       failure: function(){
           // handle the failure of request
       }
    });

Posting Permissions

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