1. #1
    Sencha User
    Join Date
    May 2010
    Posts
    11
    Vote Rating
    0
    michail_w is on a distinguished road

      0  

    Default Desktop - load JSON data into grid

    Desktop - load JSON data into grid


    Hello,
    I'm trying to edit web desktop example.
    I want to display standard Desktop grid, but i want to display external data. I tried to modyfy this code:
    Code:
    ds: new Ext.data.Store({
           reader: new Ext.data.ArrayReader({}, [
               {name: 'surname'},
               {name: 'name'},
               {name: 'age', type:'number'},
               {name: 'lastVisit', type:'date', dateFormat: 'Y-m-d H:i'}
            ]),
            data: Ext.grid.dummyData
    }),
    but my changes make desktop only with background and icons. I want to load JSON data from external file. Not from local Array (ext.grid.dummydata). Do you have any ideas?

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Have a look at the grid examples (you need to configure a store proxy for your remote data location).

  3. #3
    Sencha User
    Join Date
    May 2010
    Posts
    11
    Vote Rating
    0
    michail_w is on a distinguished road

      0  

    Default


    I tried this code:
    Code:
    ds: new Ext.data.Store({
           proxy: new Ext.data.HttpProxy({url: 'json.php'}),
           reader: new Ext.data.JsonReader({
                totalProperty: 'total',
                successProperty: 'success',
                root: 'database',
                messageProperty: 'message'
           }, [
                {name: 'surname'},
                {name: 'name'},
                {name: 'age'},
                {name: 'lastVisit', type:'date', dateFormat: 'Y-m-d H:i'}
           ])
    }),
    but it doesn't work. Can someone fix my mistakes?

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Are you loading the store (use autoLoad:true if you don't)?

    ps. Does json.php match the reader as you defined it?

  5. #5
    Sencha User
    Join Date
    Sep 2009
    Location
    Calgary, Alberta, Canada
    Posts
    638
    Vote Rating
    2
    CrazyEnigma is on a distinguished road

      0  

    Default


    What does json.php return?

    Did you configure the grid's columns correctly?

  6. #6
    Sencha User
    Join Date
    May 2010
    Posts
    11
    Vote Rating
    0
    michail_w is on a distinguished road

      0  

    Default


    Is autoLoad corectly implemented?
    Code:
    ds: new Ext.data.Store({
           proxy: new Ext.data.HttpProxy({url: 'json.php'}),
           reader: new Ext.data.JsonReader({
                totalProperty: 'total',
                successProperty: 'success',
                root: 'database',
                messageProperty: 'message'
           }, [
                {name: 'surname'},
                {name: 'name'},
                {name: 'age'},
                {name: 'lastVisit', type:'date', dateFormat: 'Y-m-d H:i'}
           ]),
         autoLoad:true
    }),
    json.php returns:
    Code:
    {'database':[{'surname':'Wójtowicz','name':'Michał','age':19,'lastVisit':'2010-01-01 12:00'}]}

  7. #7
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Correct (although you should remove totalProperty, successProperty and messageProperty).

    If you still don't see anything, then you have to debug (use the Firebug Net tab to see if the server request and response are correct).

  8. #8
    Sencha User
    Join Date
    May 2010
    Posts
    11
    Vote Rating
    0
    michail_w is on a distinguished road

      0  

    Default


    Thank you, it works!

Similar Threads

  1. Load JSON data into a Grid
    By abcdef in forum Ext 3.x: Help & Discussion
    Replies: 13
    Last Post: 3 Apr 2010, 11:12 AM
  2. how can i load data from json to grid
    By anoop abbot in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 16 Apr 2009, 1:17 AM
  3. Load returned json data into a grid.
    By whdanj in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 15 Apr 2009, 5:26 AM
  4. Steps to load JSON/XML data into a Grid?
    By jpnet in forum Community Discussion
    Replies: 1
    Last Post: 11 Dec 2008, 8:02 AM
  5. load data then desktop
    By Matt2012 in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 31 Oct 2007, 4:09 AM

Thread Participants: 2

Tags for this Thread