Results 1 to 5 of 5

Thread: [FIXED-EXTJSIV-1260][B3] Direct Proxy not properly building json for paging requests

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Boca Raton, FL
    Posts
    94

    Default [FIXED-EXTJSIV-1260][B3] Direct Proxy not properly building json for paging requests

    Here is a stripped down super simple grid. It should be using start and limit (but not page), which are the only parameters to the Ext.Direct api call server side.

    Code:
    Ext.Loader.setConfig({enabled: true});
    //set namespaces
    Ext.ns(
      'App',
      'App.MyApp',
      'App.MyApp.State',
      'App.MyApp.State.Grids',
      'App.MyApp.State.Stores',
      'App.MyApp.Types',
      'App.MyApp.Types.Grids',
      'App.MyApp.Types.Stores'
    );
    //load requirements
    Ext.require([
     'Ext.direct.*',
     'Ext.grid.*',
     'Ext.data.*'
    ]);
    
    Ext.regModel('MyModel', {
     fields  : [
         { name: 'ID', type: 'int' }
        ],
     idProperty : 'ID'
    });
    Ext.define('App.SomeApp.Types.Stores.MyStore', {
     extend  : 'Ext.data.Store',
     constructor : function(config) {
         var cfg = config ? config : {};
         Ext.apply(cfg, {
          model  : 'MyModel',
          pageSize : 20,
          proxy  : {
              directFn  : Ext.ss['MyDirectAPI'].getAll,
              paramsAsHash : false,
              paramOrder  : 'start,limit',
              pageParam  : undefined, //do not use page
              reader   : {
                   idProperty  : 'ID',
                   root   : 'ROWS',
                   totalProperty : 'RECORDCOUNT',
                   type   : 'json'
                  },
              type   : 'direct'
             },
          storeId  : 'MyStore'
         });
            App.MyApp.Types.Stores.MyStore.superclass.constructor.call(this, cfg);
        }
    });
    
    Ext.define('App.MyApp.Types.Grids.MyGrid', {
     extend  : 'Ext.grid.GridPanel',
     constructor : function(config) {
         var cfg = config ? config : {};
         Ext.apply(cfg, {
          columns  : [
              new Ext.grid.RowNumberer(),
              {
               header: "ID",
               dataIndex: 'ID',
               width: 56
              }
             ],
          padding : 2,
          store  : App.MyApp.State.Stores.MyStore,
          title  : 'My Grid Table'
               });
            App.MyApp.Types.Grids.MyGrid.superclass.constructor.call(this, cfg);
        }
    });
    
    Ext.onReady(function(){
     //Load Direct API
     Ext.direct.Manager.addProvider(Ext.ss.APIDesc);
     
     //Initialize States
     App.MyApp.State.Stores.MyStore = new App.MyApp.Types.Stores.MyStore();
     App.MyApp.State.Grids.MyGrid = new App.MyApp.Types.Grids.MyGrid();
     //do UI
     new Ext.container.Viewport({
      items : [{
         autoScroll: true,
         items : [
            App.MyApp.State.Grids.MyGrid
           ],
         layout : 'fit',
         title : 'My App',
         xtype : 'panel'
        }],
      layout : 'fit',
      margin : 0,
      xtype : 'viewport'
     });
     App.MyApp.State.Stores.MyStore.loadPage(1);
    });
    Here is the Direct API:

    Code:
    Ext.ns('Ext.ss');Ext.ss.APIDesc = {"actions":{"MyDirectAPI":[{"name":"getAll","len":2}]},"namespace":"Ext.ss","type":"remoting","url":"\/ExtDirect\/Router.cfm"};
    And here is the post being sent to the server, note the null values for data:

    Code:
    {"action":"MyDirectAPI","method":"getAll","data":[null,null],"type":"rpc","tid":1}

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448

    Default

    The Ext.Direct Grid example is sending the correct params so I took a closer look at the code you provided and I see what probably is breaking paging... in your proxy you have this line:

    Code:
    pageParam  : undefined, //do not use page
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Boca Raton, FL
    Posts
    94

    Default

    Thanks for taking a quick look. How is that breaking things? The docs say for pageParam "The name of the 'page' parameter to send in a request. Defaults to 'page'. Set this to undefined if you don't want to send a page parameter".

    Wanting to maintain backward compat with existing server API methods that expect only start and limit, I would think it would be kind of important to have the option to not include the page parameter in the passed json data.

    However, just to be thorough in testing, I modified my server side to accept a third parameter, confirmed getAll had a len of 3 in the new API definition, removed the pageParam line, and changed paramOrder to 'start,limit,page'. All this did was add a 3rd null to the json post.

    Code:
    {"action":"MyDirectAPI","method":"getAll","data":[null,null,null],"type":"rpc","tid":1}

  4. #4
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Boca Raton, FL
    Posts
    94

    Default

    I see the issue. The paging, sorting, and filtering are all built into a struct int he example, being sent as a single param. However, once I set use paramsAsHash:false or paramOrder, then it blows up again sending a single null parameter (server side set to single param for the struct now).

  5. #5
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256

    Default

    There was a bug where paramOrder wasn't correctly accepting a string based paramOrder, this will be fixed in the next release, so the below won't work until this is patched.

    FYI if you specify a paramOrder there's no need to null out the pageParam, since it won't send it anyway.

    Also, you'll probably want to use the "simpleSortMode" parameter on the proxy, which just sends the field/direction, as opposed to the JSON encoded version.

    So your proxy config would look like:
    Code:
    proxy: {
        paramOrder: 'sort|dir',
        simpleSortMode: true,
        type: 'direct',
        directFn: TestAction.getGrid
    }
    Once you've configured the direct method to take 2 params it will work as you expect.
    Twitter - @evantrimboli
    Former Sencha 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.

Similar Threads

  1. Adding HTTP Headers to Direct Requests
    By dancablam in forum Ext.Direct
    Replies: 2
    Last Post: 10 Jun 2013, 5:24 AM
  2. Replies: 2
    Last Post: 8 Apr 2011, 7:23 AM
  3. Replies: 1
    Last Post: 4 Apr 2011, 9:30 PM
  4. JSON, Paging and Memory Proxy
    By gbegley in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 13 Oct 2010, 10:49 AM
  5. memory proxy with paging not displayed properly
    By Rajalakshmi_j in forum Ext 3.x: Help & Discussion
    Replies: 20
    Last Post: 22 Jul 2009, 3:50 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
  •