1. #1
    Ext User
    Join Date
    Jul 2009
    Posts
    14
    Vote Rating
    0
    extjs3user is on a distinguished road

      0  

    Default Dynamically load grid using direct store

    Dynamically load grid using direct store


    I am trying to load a grid panel using metadata with direct store. But data is not loaded.
    Code:
     var note = Ext.data.Record.create([
            { name: 'Summary', type: 'string' },
            { name: 'Description', type: 'string' },
            { name: 'Date', type: 'date' },
            { name: 'Type', type: 'string' },
            { name: 'ReportedBy', type: 'string' },
            { name: 'Year', type: 'string' }
        ]);
    
     var notestoreLst = new Ext.data.DirectStore({
                    paramOrder: 'taxonomyId|categoryType|rowId|caseId|start|limit|sort|dir',
                    directFn: Test.GetNoteDirect,
                    paramAsHash: false,
                    totalProperty: 'total',
                    idProperty: 'NoteId',
                    root: 'Note',
                    fields: note
            });

    am getting the following result. but the grid is not loading.

    Code:
    {
        "type":"rpc",
        "tid":2,
        "action":"Test",
        "method":"GetNoteDirect",
        "result":
            "{ \"success\":true,
                \"metaData\":{
                    \"root\":\"Note\",
                    \"totalProperty\":\"results\",
                    \"id\":\"NoteId\",
                    \"fields\":[
                        {\"name\":\"NoteId\",\"header\":\"NoteId\",\"width\":30,\"hidden\":\"true\"},
                        {\"name\":\"Date\",\"header\":\"Date\",\"width\":50,\"sortable\":true,\"renderer\":dateTimeFormat,\"menuDisabled\":true},
                        {\"name\":\"Summary\",\"header\":\"Summary\",\"width\":110,\"sortable\":true,\"menuDisabled\":true},
                        {\"name\":\"Description\",\"header\":\"Description\",\"width\":120,\"hidden\":\"true\"},
                        {\"name\":\"Type\",\"header\":\"Type\",\"width\":80,\"sortable\":true,\"menuDisabled\":true},
                        {\"name\":\"ReportedBy\",\"header\":\"Reported By\",\"width\":50,\"sortable\":true,\"menuDisabled\":true},
                        {\"name\":\"Year\",\"header\":\"Year\",\"width\":50,\"sortable\":true,\"menuDisabled\":true}
                        ]
                    },
                    \"results\":1, 
                    \"Note\" : [
                        {
                            \"NoteId\":11309,
                            \"Date\":\"\\/Date(1267165680000)\\/\",
                            \"Summary\":\"zXZX\",
                            \"Description\":\"ZXX\",
                            \"Type\":\"ResearchCase Notes\",
                            \"Year\":\"\",
                            \"ReportedBy\":\"Banumathi Seshan\"
                        }] 
                }"
            }

  2. #2
    Ext User
    Join Date
    Jun 2010
    Posts
    6
    Vote Rating
    0
    fudriot is on a distinguished road

      0  

    Default


    I am experimenting the same problem in my application. I wonder if this is a bug or missing feature.

    The same server side's response would be fine within a JsonStore.

    Any clue by an ExtJS expert?
    Last edited by fudriot; 14 Jun 2010 at 5:01 AM. Reason: typo fix

  3. #3
    Sencha User
    Join Date
    Aug 2008
    Posts
    31
    Vote Rating
    0
    Bodom78 is on a distinguished road

      0  

    Default


    Difficult to give a direct answer, however if you guys are familiar with Kohana then you can setup an instance of the Direct Module for it that I ported over.

    I have included a working example of a DirectStore with a DataGrid with the module. Maybe that can help point you in the right direction.

    Cheers.

  4. #4
    Ext User
    Join Date
    Jun 2010
    Posts
    6
    Vote Rating
    0
    fudriot is on a distinguished road

      0  

    Default


    In your example, have you tried to use metadata to describe the datasource to your DirectStore?

    Metadata are sent at the same time as data in the ajax call (see debug above). As it may be automatically generated on the service side, it allows you to spare some tedious work / maintenance on the client side.

    This feature is very convenient with JsonStore. It can be implemented as a first step towards a dynamic datagrid.

  5. #5
    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


    Why is the 'result' property in the first post a really long string? It should be JSON data!

  6. #6
    Ext User
    Join Date
    Jun 2010
    Posts
    6
    Vote Rating
    0
    fudriot is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    Why is the 'result' property in the first post a really long string? It should be JSON data!
    I don't know. But without escaping, it doesn't work either.

  7. #7
    Ext User
    Join Date
    Nov 2007
    Posts
    10
    Vote Rating
    0
    weazle is on a distinguished road

      0  

    Default


    Had the same Problem starting with ExtDirect.

    Your JSON-result looks like it has been json-encoded twice.

    On the server side, if you are using any server-side stack, do NOT return a json-encoded string within your functions, but the "raw" data. The data you are returning will later be encoded to json automatically when it gets processed by your server stack implementation.

    example in php, correct:
    Code:
    public function read() {
      $result = array();
      /* fill array ... */
      return $result;
    }
    wrong:
    Code:
    public function read() {
      $result = array();
      /* fill array ... */
      return json_encode($result);
    }

  8. #8
    Ext User
    Join Date
    Jun 2010
    Posts
    1
    Vote Rating
    0
    WormParty is on a distinguished road

      0  

    Default


    Same problem and already solved it. Look at the "result" property, it's value is a string not a config object
    So in this case, you should use JsonRaw (or JRaw in new version of Json.net) to return result