Search code examples
javascriptangularjssortingangular-ui-gridtableheader

how to remove the "clear sort" state in angular-ui-grid column header?


I see info on adding "disable sort" but not how to remove the default behavior where the 3rd click disables sort and is "neutral" on sortable headers. In reality, having a disable sort state feels broken since it does not actually change the sort order. How do I get rid of the 3rd state and just have it toggle ASC and DESC?

   columns:any[] = [
     { name:'Email', field:'email' },
     { name:'Sessions', field:'sessionCount', enableSorting:false}   //something like enableClearSorting:false
   ]

Solution

  • You can use the suppressRemoveSort attribute:

    columns:any[] = [
         { name:'Email', field:'email' },
         { name:'Sessions', field:'sessionCount', enableSorting:false, suppressRemoveSort: true }
       ]