You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the "sort" example in table, the first time the table is sorted, the "products" variable, which is passed as the "value" attribute to p-table, is sorted according to the selected sort option, however, this does not happen on any subsequent sorts, staying how it was after the first sort.
Forcing an update such as by doing this.products = [...this.products]; on the (onSort) event makes the p-table ngOnChanges run (I suppose) which makes it correctly sort the products variable. However the expected behaviour is that this would happen without the need to force this update.
Environment
This was first noticed on a standard angular v17 production project, but can be reproduced in e.g. stackblitz
See that the "products" data source is being correctly sorted after clicking on the sort buttons on the header
Comment "table-single-column-sort-demo.ts"'s line 25 (this.products = [...this.products];)
See that the "products" data source is only being correctly sorted after clicking the sort buttons on the header the first time, and after that it does not get sorted again when clicking the sort buttons again. (note that the table itself keeps getting correctly sorted, it is just the "products" variable that does not get sorted)
For cases without the stackblitz project linked above:
Add a function to print the "products" data source after sorting
Notice that the "products" variable only gets sorted the first time
Expected behavior
It would be expected that the variable used as the data source via the p-table's "value" property would get sorted every time there is a sorting action, not just the first time.
The text was updated successfully, but these errors were encountered:
So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you open a new issue so we can include it in our roadmap?
Thanks a lot for your understanding!
Best Regards,
Describe the bug
Using the "sort" example in table, the first time the table is sorted, the "products" variable, which is passed as the "value" attribute to p-table, is sorted according to the selected sort option, however, this does not happen on any subsequent sorts, staying how it was after the first sort.
Forcing an update such as by doing
this.products = [...this.products];
on the (onSort) event makes the p-table ngOnChanges run (I suppose) which makes it correctly sort the products variable. However the expected behaviour is that this would happen without the need to force this update.Environment
This was first noticed on a standard angular v17 production project, but can be reproduced in e.g. stackblitz
Reproducer
https://stackblitz.com/edit/mulxe5-psdggj?file=src%2Fapp%2Ftable-single-column-sort-demo.html,src%2Fapp%2Ftable-single-column-sort-demo.ts
Angular version
17.3.8
PrimeNG version
17.17.0
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
20.9.0
Browser(s)
No response
Steps to reproduce the behavior
In the stackblitz project linked above:
See that the "products" data source is being correctly sorted after clicking on the sort buttons on the header
Comment "table-single-column-sort-demo.ts"'s line 25 (
this.products = [...this.products];
)See that the "products" data source is only being correctly sorted after clicking the sort buttons on the header the first time, and after that it does not get sorted again when clicking the sort buttons again. (note that the table itself keeps getting correctly sorted, it is just the "products" variable that does not get sorted)
For cases without the stackblitz project linked above:
Copy the code in the documentation
Add a function to print the "products" data source after sorting
Notice that the "products" variable only gets sorted the first time
Expected behavior
It would be expected that the variable used as the data source via the p-table's "value" property would get sorted every time there is a sorting action, not just the first time.
The text was updated successfully, but these errors were encountered: