ngx-datatable
ngx-datatable copied to clipboard
Sorting DESC on first column click instead of ASC
I'm submitting a ... (check one with "x")
[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
Current behavior The current sorting behavior is working ASC on the first click and there is not any property to specify the the default sorting direction on the first click.
Expected behavior It would be great to have a property, lets say 'sortingDirectionAtFirst', where we could change the sorting direcction on the first click. currently the datatable is working very well, but there is not any way to change the direccion on the first click to DESC for all the columns.
<ngx-datatable
class="material"
[rows]="reportData"
[sortingDirectionAtFirst]="DESC">
</ngx-datatable>
What is the motivation / use case for changing the behavior? It would be nice to have the ability to change the sorting direction at the first click.
Please tell us about your environment:
- Table version: 10.2.3
- Angular version: 4.0.0
- Browser: All
- Language: TypeScript 2.4.2
Thank you
@maustand what about the direction of subsequent sorts sorting direction at first click? Example of that would be to sort by last name, then by first, then by middle. But someone might want the sort direction different for each header cell clicked, or depending on the specific context. It might be easier to get a callback when header cell is clicked and you can decide for yourself the direction.
Chiming that I would find this feature very useful
Totally behind this idea - in almost every case, for our use cases, the first click would want to be descending, as opposed to ascending. Having this controllable as an option per column would be awesome.
I would also find this very useful. It would be nice to have the option to choose the order of the initial sort order.
+1
Use this [sorts]="[{prop: 'name', dir: 'asc'}]" it will set sort direction to ascending order. when you click on column for the first time it will sort in desc direction
Use this [sorts]="[{prop: 'name', dir: 'asc'}]" it will set sort direction to ascending order. when you click on column for the first time it will sort in desc direction
It will make this column sorted by default when the table is rendered
I would find this very useful too.
Is there any known workaround for this one?
Would second this request but would need it to be on a column by column basis. Example use case, We have a table of items with string and number columns. We want to configure the string columns to sort ascending by default and the numbers to sort descending by default.
I support this issue too
@DanNisenson I have made a workaround for this tho. First I converted numbers to negative ones and had css class to change icon in the header, and then converted value in the cell again to positive number.
what do you mean by:
First I converted numbers to negative ones
Well column was with numbers, so by X * -1, it goes in other direction
I see. I have multiple data types in my row cells so I'm gonna need to find another solution, but thanks for the tip!