Primeng: DataTable toggle column sort 'off' state

Created on 27 Jun 2017  路  39Comments  路  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[ ] 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
Column sorting in the DataTable component has two states - Ascending and Descending - meaning it is possible to sort by the column contents, but not to disable an active column sort.

Expected behavior
Clicking in a sortable column header a third time could disable the selected sort, reverting to the default (un)sort(ed) state.

Minimal reproduction of the problem with instructions

Issue can be seen on the demo page - https://www.primefaces.org/primeng/#/datatable/sort
Clicking a column title toggles between ascending and descending states, but offers no ability to return to the default unsorted state.

What is the motivation / use case for changing the behavior?

It would be useful to be able to revert to the default sort state of the DataTable without having to trigger a .reset() of the DataTable component.

Please tell us about your environment:

  • Angular version: 4.1.3

  • PrimeNG version: 4.0.3

Most helpful comment

The behavior is the same with the new TurboTable. Any news or workaround ?

All 39 comments

Not sure but we'll keep it to see if more users demand it. Thank you.

@cagataycivici No probs - thanks for the reply!
I'll likely implement this in my fork, so if and when I do I'll create a PR so you can take a look :)
Keep up the great work!

Hi, recently i recommended PrimeNg (DataTable) to one of my collegues and he said that the table is really nice and have enough of features. But the first and only odd thing he found that it is impossible to move back to default state of sorting. So, ++ for this feature.

@danielkay @cagataycivici
This would be a really useful feature

+1 for this feature

We have also implemented primeNg Datatable in our application and found it really nice. The only thing client is missing is getting back to default state on third click on any column header.

+1

+1

+1

+1

+1

For our application we miss the default state on the third click.
So, ++ for this feature.

/sign

Definitly a nice feature to have

This is not so difficult to implement yourself, by listening to the onSort event, and keeping track of the last sorted field.

However, since the current Sort implementation will mutate the provided value array, this means that calling reset on the grid is not enough to actually return the data to the pre-sorted order. Rather, you have to reset the grid, and then provide the original data again for re-binding.

If the DataTable didn't mutate the array, but rather a clone, this would make reset work as expected and make implementing this much easier.

+1

+1

+1

+1

+1

+1 .

Any update on this? @cagataycivici

+1

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.

surprised, where can i get more informations about that?

@juri33 I believe he's referring to #4743, which is due mid february.

@jotapsl thx

The behavior is the same with the new TurboTable. Any news or workaround ?

Hi, I click on button after that modal is pop up. In modal I took p-table with sorting.I closed the p-table and again open sorting remain as it is. nay solution to reset sorting in modal data.

+1

+1

+1

+1, why hasn't this been added yet?

+1 to this feature. I really need this.
Any other way to achieve this ?

++1

I'm still not seeing a way to do this in PrimeNG 11. Is it safe to assume it's never gonna happen?

@bgl3317 it would appear not, I guess. Perhaps if someone were to create a new issue flagged against the current version of the component it might stand a better chance of getting picked up?
I've now not used PrimeNG - or indeed Angular itself - for years, so have little incentive to attempt to re-initiate the discussion in that respect. Is there anyone else who is actively using PrimeNG and would like to pick up that mantle?

+1

@bgl33117 since this issue is closed and referring to DataTable which does not exist any more, this will certainly not be worked on.As @danielkay said this needs to be followed up in a new issue for the current component which already exists as #8013. There is already an implementation in #8072, but Prime prefers to implement such changes themselves, which sometimes may take a while. I will help if you upvote #8013 or buy PRO support.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

svideau picture svideau  路  30Comments

mohan1304 picture mohan1304  路  37Comments

SpiderPork picture SpiderPork  路  70Comments

nsksaisaravana picture nsksaisaravana  路  32Comments

RaviMovva picture RaviMovva  路  33Comments