Results 1 to 6 of 6

Thread: sort properties not being sent on Ajax Request

  1. #1
    Sencha MVP Team Member
    Join Date
    Sep 2016
    Location
    Kennewick, WA
    Posts
    150
    Answers
    15

    Default sort properties not being sent on Ajax Request

    The following store definition is not sending the "sort" parameters when the request is being sent. Version of ExtJS is 6.5.3

    Code:
    Ext.define('MyApp.store.transMgrAcaTier1Store', {
        extend: 'Ext.data.Store',
    
    
        requires: [
            'MyApp.model.transMgrAcaTier1Model',
            'Ext.data.proxy.Ajax',
            'Ext.data.reader.Json',
            'Ext.util.Sorter'
        ],
    
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                remoteSort: true,
                storeId: 'transMgrAcaTier1Store',
                model: 'MyApp.model.transMgrAcaTier1Model',
                proxy: {
                    type: 'ajax',
                    reader: {
                        type: 'json',
                        rootProperty: 'data'
                    }
                },
                sorters: {
                    direction: 'DESC',
                    property: 'TransferTime'
                }
            }, cfg)]);
        }
    });
    And the code generating the request

    Code:
    getTier1PayrollFiles: function(field) {
            console.log("trigger get payroll type file list");
            var store = field.getStore();
            storeproxy = store.getProxy();
            storeproxy.url = "../ACA/TransferService.aspx?method=GetTier1&WI=" + Ext.getCmp('cntTransferMgr').MenuID + "&UID=" + Ext.getCmp('cntTransferMgr').UID + "&companykey=" + field.getValue() + "&transfertypeid=1";
            store.load();
            // Comment to get changes made
        },
    Parameters being applied to the request include
    Code:
    • method: GetTier1
    • WI: 9503
    • UID: 5SMTWXTKKB00XY8KAARGULDZSOKT8HAY1CRHSY7M
    • companykey: ACA002-000004
    • transfertypeid: 1
    • _dc: 1521583666736
    • page: 1
    • start: 0
    • limit: 25
    Now when reviewing parameters sent using ExtJS 4.2 (current production) parameters being sent are as follows:

    Code:
    _dc 1521587490106
    companykey ACA002-000005
    limit 50
    method GetTier1
    page 1
    sort [{"property":"TransferTime","direction":"DESC"}]
    start 0
    transfertypeid 1
    UID E5LYMR04Q42B2YK4LNCTFTDP2FJGQJIVRT2FJPFR
    WI 9503
    You can see the "sort" parameter is being sent with this request and is lacking in the ExtJS 6.5 request.

    Current code is further developed using the latest version of Sencha Architect while the current production was developed using standard code editing.

    Is there some setting missing in the new development stopping the "sort" property from being appended?

    Per documentation found at (https://docs.sencha.com/extjs/6.5.1/...roxy.Rest.html) it states outright
    Note that Rest proxy inherits from Ext.data.proxy.Ajax, which already injects all of the sorter, filter, group and paging options into the generated url. See the Ext.data.proxy.Ajax for more details.
    So why is "sort" parameter not being sent while page, start and limit are being automatically appended?
    Last edited by aallord; 21 Mar 2018 at 7:43 AM. Reason: Added "remoteSort: true" to the store definition. Produces the same results, sort parameters are not sent.

  2. #2
    Sencha User yeghikyan's Avatar
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default

    You have forgotten 'remoteSort: true' in the store config.
    "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." – Edsger W. Dijkstra

  3. #3
    Sencha MVP Team Member
    Join Date
    Sep 2016
    Location
    Kennewick, WA
    Posts
    150
    Answers
    15

    Default

    Quote Originally Posted by yeghikyan View Post
    You have forgotten 'remoteSort: true' in the store config.
    Thanks for the idea, but I've tried setting remoteSort: true and the results are the same. "sort" parameter is still not sent with the ajax request. I only wish it would be that simple...

  4. #4
    Sencha MVP Team Member
    Join Date
    Sep 2016
    Location
    Kennewick, WA
    Posts
    150
    Answers
    15

    Default

    Additional information to try and discover and answer to this problem which is starting to look more like bug...

    Sorters definition used in ExtJS 4.2.x without using Sencha Architect is as follows:
    Code:
    sorters: [
         {
              property: 'TransferTime',
              direction: 'DESC'
         }
    ],
    Now the sorters definition using ExtJS 6.5.x and Sencha Architect to define the store looks like this:
    Code:
    sorters: {     direction: 'DESC',
         property: 'TransferTime'
    }
    Notice the missing brackets [ ] in the Architect store definition. I manually edited the store file using a code editor to add the brackets. End result of testing this way was still "sort" parameters were not being sent to the ajax request.

  5. #5
    Sencha User yeghikyan's Avatar
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default

    In fiddle it works


    Send params:
    ---

    • method:
      GetTier1
    • WI:
      wi
    • UID:
      uid
    • companykey:
      companyKey
    • transfertypeid:
      1
    • _dc:
      1521710628367
    • page:
      1
    • start:
      0
    • limit:
      25
    • sort:
      [{"property":"TransferTime","direction":"DESC"}]

    ---
    "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." – Edsger W. Dijkstra

  6. #6
    Sencha MVP Team Member
    Join Date
    Sep 2016
    Location
    Kennewick, WA
    Posts
    150
    Answers
    15

    Default

    I will need to dig further into this. Yes, I confirmed "sort" is sent from the fiddle but it still is not being sent from the development server.

    When testing this time I even commented out in file the model requirement (this is no easy task in Architect) to see if that was making a difference. Clearly this points to some configuration setting in the Architect project or something directly being removed from my server. I eliminate the server since I've production servers using ExtJS 4.2.x that are currently sending as expected and working functionally. The current difference is this is our next version using Architect and ExtJS 6.5.3. Production was manually written code as compared to auto-generated code in Architect. Ergo, none of the store definitions use the "requires" section nor a "constructor"...

    I can only dig in more to see what could be causing the issue. I appreciate your help.

    Problem: This was a case of using store = field.getStore(). This was actually getting the store of the combobox and not the store needed to return the data. The CompanyStore did not have remoteSort: true, nor did it have a "sorters" definition. When expecting records of files that have been previously uploaded it was sending the method for returning these records, but the CompanyStore was sent without sorting enabled. So yes, it was one of the programmers "duh" moments of simply assuming everything was correctly being defined by overlooking the simplistic mistake in lieu of checking that first.
    Last edited by aallord; 22 Mar 2018 at 10:00 AM. Reason: Updated due to discovering the issue / Closed Issue

Similar Threads

  1. Replies: 1
    Last Post: 18 Aug 2014, 4:35 PM
  2. Ext.Ajax.request properties
    By lcurrens in forum Sencha Architect 2.x: Help & Discussions
    Replies: 1
    Last Post: 21 Feb 2012, 6:51 PM
  3. Replies: 0
    Last Post: 31 Mar 2011, 9:22 AM
  4. Need help posting nested properties in Ajax request
    By andyatmiami in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 13 Aug 2009, 9:10 PM
  5. Ext.Ajax.request return Ext.Ajax has no properties
    By etiennesamson in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 4 Aug 2007, 11:43 PM

Tags for this Thread

Posting Permissions

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