Skip to content

Replies

0
Aidan Reel
Aidan Reel answered on May 12, 2015 5:36 PM

Thanks for the update.

In the meantime I adopted your code and this is what I have working now. Posting it so others coming across this post can compare and contrast.

We have a column that is always sorted descending by default, this played well since it allowed the unsort to become a resort on that default column and the CSS and visual clues worked nicely of us.

features: [{    
     name: 'Sorting',    
     type: 'remote',   
     mode: 'single',    
     applySortedColumnCss: false, 
// remove default sort background color but leave visual clue in header    
    columnSorting: function (evt, ui) {        
        if ((ui.owner.option("firstSortDirection") == ui.direction) && ui.owner.grid.dataSource.settings.sorting.expressions.length != 0) {            
           if (ui.owner.grid.dataSource.settings.sorting.expressions[0].fieldName == ui.columnKey && ui.columnKey != "NameOfYourDefaultSortedColumn") {            
                 // our grid has a default sort column so sort by it in order to remove current sort.                 
                 $(gridElement).igGridSorting("sortColumn", "NameOfYourDefaultSortedColumn", "descending");                 
                  return false;            
            }        
        }        
       return true;    
    }
}]

 

Thanks again for your help.

Regards

Aidan

0
Aidan Reel
Aidan Reel answered on May 11, 2015 6:27 PM

Hi

Unfortunately this doesn't work.

When I asked the question the grid in question had a mode of "multi", so I assumed that was part of the reason the code didn't work.

Since then, the multiple sort requirement was been dropped so I retried this code with a grid with mode = single but it still fails.

1. On the third click (back to firstSortDirection), the unsort does not occur and further clicking has no effect.

2. Clicking on a new / different column heading has no effect but the header gets the "sorted" background color, and the previous column retains its "sorted" background color.

Regards

Aidan

0
Aidan Reel
Aidan Reel answered on Apr 27, 2015 1:40 PM

Hi Hristo,

Thanks for the reply.

Sorry forgot to add the platform info, we are on 14.2 with plan to move to 15.1 but not immediately. If you have a solution for 14.2 that would be great.

Regards

Aidan