1. #1
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    88
    Vote Rating
    5
    whirling dervish is on a distinguished road

      0  

    Default Help with grid / store remote sorting under ExtJS 4.1.3

    Help with grid / store remote sorting under ExtJS 4.1.3


    My ultimate goal is to have a grid with remote sorting, but this seems like it is supported by setting 'remoteSort: true' on the store backing the grid itself.

    My problem is once this is set and the columns are marked as sortable, clicking on sort does nothing. Is the expectation here that I would be implementing some custom logic on the grid sortchange event or do I have to configure something else to get the remote sorting?

    Can anyone help me out by either pointing to further documentation or explaining what is needed to make remote sort work?

    Oh, and this is under ExtJS 4.1.3, apparently 4.2 is going to bring some improvements to the Grid, but I can't upgrade until it goes stable.
    Last edited by whirling dervish; 4 Feb 2013 at 7:13 AM. Reason: corrected typo, casing is correct in the code

  2. #2
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    86
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      0  

    Default


    Besides marking the store as having "remoteSort: true" (careful on the casing...), you shouldn't have to do anything else, at least not on the ExtJS side. What you *will* need to do is to implement logic on the server side to:
    • Recognize the sortParam that is sent through on the remote sort request (this can be configured on your store's proxy)
    • Produce a record set that reflects the requested sortParam's configuration
    • Return back a response that is in a format acceptable to your store's configured Reader
    Basically, when you do remote sorting, you are making a handshake with the grid that the data it requests via the store's proxy will be returned in the "direction" requested. It has no way of knowing whether or not this data is, in fact, sorted correctly, but merely assumes that it is because you have passed the sorting responsibilities off to a remote source.

  3. #3
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    88
    Vote Rating
    5
    whirling dervish is on a distinguished road

      0  

    Default


    Hmm, I am not seeing the sort menu do anything client side. I don't see any requests being sent to the server and I don't see 'sortchange' being fired on my grid.

    Anyone have any idea what might be going on here or how I could better debug this?

    An important distinction is that I am using the lockable grid here, maybe I am seeing a bug.

    EDIT: Just tried switching the grid over to a normal grid and I am seeing the same behavior.

    EDIT 2: Ah it looks like it might be due to dataIndex missing in my column definitions. Adding that makes the sort event fire as expected.

  4. #4
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    88
    Vote Rating
    5
    whirling dervish is on a distinguished road

      0  

    Default


    Is it possible to set a default sort on a remote sorting store?

    A few threads I've encountered mention 'sortInfo' on the store, but I am not seeing that documented anywhere, and it doesn't seem to be working for me.

  5. #5
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    86
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      0  

    Default


    You should just be able to set the sorters config on the store itself.


    Code:
    sorters:[
        { 
            property:'age',         
            direction:'DESC'
        },
        { 
            property:'firstName',         
            direction:'ASC'
        }
    ]

  6. #6
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    88
    Vote Rating
    5
    whirling dervish is on a distinguished road

      0  

    Default


    Thanks, don't know how I missed that in the documentation. That works like a charm.

    Only thing wrong with it is that it doesn't mark the column with the initial sort as being sorted, but that is a pretty minor issue.

  7. #7
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    86
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      0  

    Default


    That's odd, it should mark it.

  8. #8
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    88
    Vote Rating
    5
    whirling dervish is on a distinguished road

      0  

    Default


    Maybe it's because the property name doesn't match the name of the column.

Thread Participants: 1

Tags for this Thread