Results 1 to 4 of 4

Thread: Any good way to start grid already sorted?

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    15
    Vote Rating
    1
      0  

    Default 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
      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
    9,493
    Vote Rating
    256
      0  

    Default

    Thanks for taking the time to post a follow-up.


    Join me at SenchaCon 2016!

  4. #4
    Sencha Premium Member
    Join Date
    Jan 2009
    Posts
    409
    Vote Rating
    238
      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.

Posting Permissions

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