1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    15
    Vote Rating
    1
    sneakyfildy is on a distinguished road

      0  

    Default Any good way to start grid already sorted?

    Any good way to start grid already sorted?


    I have a remote paging grid with columns and a store.
    All sorters work as they must.
    But how can I make grid be sorted on first load (which is correctly sorted load).
    I do not want to make one more request just to render that triangle in the column header.
    Also I do not want to hack somehow onload event to render it manually.
    I wonder if there is NORMAL/standard way to do that.

    Once again, what should I do to see sort triangle over sorted column on initial/first load of the grid store?

  2. #2
    Sencha User
    Join Date
    Aug 2011
    Posts
    15
    Vote Rating
    1
    sneakyfildy is on a distinguished road

      1  

    Default


    Please close thread.My bad.This piece of extjs-code would do that
    Code:
    if (first) {
                hd = this.down('gridcolumn[dataIndex=' + first.property  +']');
                if (hd) {
                    hd.setSortState(first.direction, false, true);
                }
    }

    But I have first column with different dataIndex then its sorter's dataIndex, sorry.

  3. #3
    Sencha - Support Team
    Join Date
    Feb 2013
    Location
    California
    Posts
    3,676
    Vote Rating
    70
    Gary Schlosberg is a jewel in the rough Gary Schlosberg is a jewel in the rough Gary Schlosberg is a jewel in the rough

      0  

    Default


    Thanks for taking the time to post a follow-up.
    Get on the Fast Track with Sencha Training http://sencha.com/training

    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our recruiting manager: sheryl@sencha.com

  4. #4
    Sencha Premium Member
    Join Date
    Jan 2009
    Posts
    327
    Vote Rating
    48
    firefoxSafari is a jewel in the rough firefoxSafari is a jewel in the rough firefoxSafari is a jewel in the rough

      0  

    Default


    You can use the sorters config option on the store that you define for the grid. For example,

    Code:
            Ext.create('Ext.data.Store', {
                storeId:'...',
                fields:[
                ...
                ],
                remoteSort: true,
                remoteFilter: true,
                autoLoad: {start: 0, limit: 20},
                pageSize: 20,
                proxy: {
                ...
                },
                sorters: [{
                    property: 'propertyName',
                    direction: 'ASC'
                }]
            });
    This indicates that the first load request the store makes should include sorting parameters. The server will return the correctly sorted values, there will be no extra request, and the grid header icons will render correctly. Further column sorts on the grid work as normal.