1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    7
    Vote Rating
    0
    seha is on a distinguished road

      0  

    Default How to exclude certain rows from sorting?

    How to exclude certain rows from sorting?


    Hi all.

    I am new to ExtJS and i have written an web-application which features a GridPanel (grouped and ungrouped) and I want to prevent sorting certain rows (which represent summary rows).

    I have already tried
    http://www.sencha.com/forum/showthre...-grid-s-footer
    but it didn't work for me.

    I am using ExtJS 3.4.

    Can somebody give some hints. Thank you very much in advance.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,643
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    If you don't want a column to be sortable by clicking on the header, specify the 'sortable' config to false on the column.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    7
    Vote Rating
    0
    seha is on a distinguished road

      0  

    Default


    Hi mitchellsimoens,

    thanks for your reply.

    I dont't want to prevent sorting on a column. I want to exclude certain rows from sorting.
    I tried to remove the rows when the sortchange event is fired and insert them afterwards at the same position in the grid. But this only works for ungrouped grids.

    An alternative approach would be to create a custom sorting function. All the examples I found didn't fit my needs.

    I tried the following code (http://www.sencha.com/forum/showthre...-grid-s-footer), but I always get the error "this.fields.get(f) is undefined".

    PHP Code:
    Ext.data.MyGroupingStore Ext.extend(Ext.data.GroupingStore, {
         
    // private
        
    sortData : function(fdirection){
            
    direction direction || 'ASC';
            var 
    st this.fields.get(f).sortType;
            var 
    fn = function(r1r2){
                var 
    row_type1 r1.data['row_type'];
                var 
    row_type2 r2.data['row_type'];
                   if ((
    row_type1 == 'sum') && (direction == 'ASC'))
                       return 
    1;
                   if ((
    row_type2 == 'sum') && (direction == 'ASC'))
                       return -
    1;
                   if ((
    row_type1 == 'sum') && (direction == 'DESC'))
                       return -
    1;
                   if ((
    row_type2 == 'sum') && (direction == 'DESC'))
                       return 
    1;
                            
                   var 
    v1 st(r1.data[f]), v2 st(r2.data[f]);
                   return 
    v1 v2 : (v1 v2 ? -0);

            };
            
    this.data.sort(directionfn);
            if(
    this.snapshot && this.snapshot != this.data){
                
    this.snapshot.sort(directionfn);
            }
        }
    }); 
    Is there a detailed example of how to create a custom sorting function?

    Thanks in advance!

  4. #4
    Sencha User
    Join Date
    Aug 2009
    Posts
    480
    Vote Rating
    1
    plalx has a spectacular aura about plalx has a spectacular aura about

      0  

    Default


    What would be the use case for that?

  5. #5
    Sencha User
    Join Date
    Aug 2011
    Posts
    7
    Vote Rating
    0
    seha is on a distinguished road

      0  

    Default


    Hi scarsick,

    the rows that i want to leave on the same position are representing summary rows in the GridPanel.
    After examing the source code I was able to solve the problem.

    Cheers,

    Seha