1. #11
    Ext User
    Join Date
    Aug 2007
    Posts
    3
    Vote Rating
    0
    cunami is on a distinguished road

      0  

    Default Possible solution

    Possible solution


    Quote Originally Posted by spacyspacy View Post
    This applies only to the loading sort of the grid, not the column header click sorts.

    Anyone has found a solution for this problem?
    I am not sure, but I think that should work

    While creating a reader (I'll take for this example XmlReader) object, you have to pass recordType parameter. There you specify list of your names, e.g.
    Code:
    [ 'col1, 'col2', 'col3' ]
    , and this later is passed to Ext.data.Record.create(), according to the docs. And on its documentation there is a config option "sortDir". So if you pass not only the name, but configuration options too, then it should work:

    Code:
    [ {name: 'col1', sortDir: 'DESC'}, 'col2', 'col3' ]
    I think I have tried that, but I am not sure anymore Try and see

  2. #12
    Ext User
    Join Date
    Jun 2007
    Posts
    27
    Vote Rating
    0
    spacyspacy is on a distinguished road

      0  

    Default


    Quote Originally Posted by cunami View Post
    Code:
    [ {name: 'col1', sortDir: 'DESC'}, 'col2', 'col3' ]
    I think I have tried that, but I am not sure anymore Try and see
    Yeah, that's it, thank you!

  3. #13
    Ext User
    Join Date
    Aug 2007
    Posts
    3
    Vote Rating
    0
    cunami is on a distinguished road

      0  

    Default


    Quote Originally Posted by spacyspacy View Post
    Yeah, that's it, thank you!
    I'm glad to help

  4. #14
    Sencha User
    Join Date
    Dec 2007
    Posts
    11
    Vote Rating
    0
    twist3r is on a distinguished road

      0  

    Question


    and what about extjs 4? how do you achieve the same result?

    thanks!

  5. #15
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Midwest, USA
    Posts
    96
    Vote Rating
    2
    Reimius is on a distinguished road

      0  

    Default


    You should probably post 4.0 topics in 4.0 threads, but here is an override that is your solution that I just made:
    Code:
    Ext.override(Ext.grid.column.Column, {    
        oppositeSort: false,
    
    
        toggleSortState: function() {
            var me = this,
                idx,
                nextIdx;
    
    
            if (me.sortable) {
                idx = Ext.Array.indexOf(me.possibleSortStates, me.sortState);
                if(this.oppositeSort && idx == -1)
                    idx = 0;
    
    
                nextIdx = (idx + 1) % me.possibleSortStates.length;
                me.setSortState(me.possibleSortStates[nextIdx]);
            }
        }
    });
    then in your column config just add the extra attribute oppositeSort: true and it will do what you want.