Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: DirectStore and GridPanel -> I have to pay for the new version

  1. #1
    Ext User
    Join Date
    Aug 2009
    Posts
    7
    Vote Rating
    0
      0  

    Default DirectStore and GridPanel -> I have to pay for the new version

    Hello,

    I spent a night try to fill a grid !
    In 5 minutes, I 'm able to have this to the client side (thanks to the ext-direct-pack) :

    Code:
    {"type":"rpc","result":{"classified": {"status":null,"name":"a","updated_at":"2009-04-29T11:21:48Z","display_address":null,"abstract":"a","estate_id":"1","end_announcement":null,"contact":null,"id":1,"owner_id":"1","start_announcement":null,"created_at":"2009-04-29T11:21:48Z"}},"status":true,"errors":[],"message":"Classifieds#index","tid":2}
    But impossible to fill the grid :

    Code:
            var store = new Ext.data.DirectStore({
              directFn: Classifieds.direct, // this function work !
              paramsAsHash: false,
              root: '',
              idProperty: 'id',
              fields: ['id', 'name']
            });
    
            var userColumns =  [
              {header: 'name', width: 160, sortable: true, dataIndex: 'name'},
              {id: 'id', header: 'id', width: 160, sortable: true, dataIndex: 'id'}
            ];
    
            var userGrid = new Ext.grid.GridPanel({
              renderTo: 'user-grid',
              title: 'Users',
              autoScroll: true,
              height: 300,
              store: store,
              columns : userColumns
            });
    
            store.load();
    I try all the examples, lots of threads and Google but impossible to find what's wrong.
    Someone can help me with this ? Thanks a lot for your help.

  2. #2
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,940
    Vote Rating
    917
      0  

    Default

    1) Your root is empty.
    2) The idProperty doesn't match anything your data has returned.
    3) The id field you've specified don't match anything your data has returned.
    Twitter - @evantrimboli
    Former framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Ext User
    Join Date
    Aug 2009
    Posts
    7
    Vote Rating
    0
      0  

    Default

    Thanks a lot for your help. However I already test the grid with :
    Code:
    root: 'classified'
    And in my data, there is and id field (not in first position).

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    126
      0  

    Default

    The root isn't 'classified'. It's 'result.classified', which is a lot better to see if you format the JSON data:
    Code:
    {
        "type": "rpc",
        "result": {
            "classified": {
                "status": null,
                "name": "a",
                "updated_at": "2009-04-29T11:21:48Z",
                "display_address": null,
                "abstract": "a",
                "estate_id": "1",
                "end_announcement": null,
                "contact": null,
                "id": 1,
                "owner_id": "1",
                "start_announcement": null,
                "created_at": "2009-04-29T11:21:48Z"
            }
        },
        "status": true,
        "errors": [],
        "message": "Classifieds#index",
        "tid": 2
    }

  5. #5
    Ext User
    Join Date
    Aug 2009
    Posts
    7
    Vote Rating
    0
      0  

    Default

    Thanks Condor. sorry for this huge mistake. I changed the root but the result is the same : the grid is empty.
    My code :
    Code:
     var store = new Ext.data.DirectStore({
              directFn: Classifieds.direct,
              paramsAsHash: false,
              root: 'result.classified',
              fields: ['name']
            });
    
            var userColumns =  [
              {header: 'name', width: 160, sortable: true, dataIndex: 'name'},
            ];
    
            var userGrid = new Ext.grid.GridPanel({
              renderTo: 'user-grid',
              title: 'Users',
              autoScroll: true,
              height: 300,
              store: store,
              columns : userColumns
            });
    
            store.load();

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    126
      0  

    Default

    Which Ext version are you using? For older Ext versions the root needs to be an array, e.g.
    Code:
    {
        "type": "rpc",
        "result": {
            "classified": [{
                "status": null,
                "name": "a",
                "updated_at": "2009-04-29T11:21:48Z",
                "display_address": null,
                "abstract": "a",
                "estate_id": "1",
                "end_announcement": null,
                "contact": null,
                "id": 1,
                "owner_id": "1",
                "start_announcement": null,
                "created_at": "2009-04-29T11:21:48Z"
            }]
        },
        "status": true,
        "errors": [],
        "message": "Classifieds#index",
        "tid": 2
    }

  7. #7
    Ext User
    Join Date
    Aug 2009
    Posts
    7
    Vote Rating
    0
      0  

    Default

    I'm using the latest version (3.0).

  8. #8
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    126
      0  

    Default

    3.0 isn't a version. The latest version is 3.0.1 and I assume you are using 3.0.0?

  9. #9
    Ext User
    Join Date
    Aug 2009
    Posts
    7
    Vote Rating
    0
      0  

    Default

    Yes, 3.0.0

  10. #10
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    126
      0  

    Default

    In that case you'll need to convert your JSON data into an array (or upgrade to 3.0.1).

Page 1 of 2 12 LastLast

Posting Permissions

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