Datatable defaultSortOrder - This should be available per column
I'm submitting a ...
[ ] bug report => Search github for a similar issue or PR before submitting
[ x ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Current behavior Default sort order is only available as a table property. https://github.com/primefaces/primeng/blob/48396c3d41728488e841b1a436668e6c4e08d879/src/app/components/datatable/datatable.ts#L1210
Expected behavior Making this property available for each column allows the user to define which sort order should be used when the column is unsorted and get sorted by user interaction.
What is the motivation / use case for changing the behavior? Sometimes we don't want the default sort order to apply equally for all columns.
-
Angular version: 4.3.6
-
PrimeNG version: 4.2.1
-
Browser: [all]
-
Language: [all]
That means you want to apply default multi sort oder. As of now it defaults to single sort order.
@sudheerj, the request is to provide a way to set up a default sort order on user click, per column.
Right now it can be done for the entire table, which means I can define if I want all the columns to be sorted in ascending or descending order, on the first click, but not individually.
As a use case, consider the following: I have a table with 3 columns: cars, rating and co2 emissions. On the first click on:
- cars th, I want the column to be sorted in ascending order, alphabetically;
- co2 emissions th, I want the column to be sorted in ascending order, because the less emissions, the better, and therefore, more relevant;
- rating th, I want the column to be sorted in descending order, because the higher the ranking, the better, and therefore, more relevant.
Right now this is impossible to achieve.
p-dataTable is deprecated and will be removed in favor of the new p-table (aka TurboTable) of 5.1.0 so closing the issue. Please try the new p-table once 5.1.0 is released.