-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table | custom state save/restore [new feature] #14461
Comments
@cervenf I needed something like you're asking for so I came up with this table-manager service. Take a look at this StackBlitz and see if it will help you. |
@critchie Sorry for late replay. Thank you very much for the answer and also code sharing. If I understand Table manager correctly it helps mainly in these 2 things: Is there some way to store/restore sorting and filtering, please? In my case, I have tree as navigation and I'm displaying data in table based on which node is selected. |
@cervenf When you create a new instance of TableManager the constructor will read in the data from local storage. Line 45 in the ngOnInit() is where new TableManager is called. If you take a look at the TableManager constructor you will see where it does the read from local storage. All the rest is standard Angular binding. The ngAfterViewInit() is needed to assign the actual table to the TableManager. I had to do it this way because the table isn’t fully built and available until AfterViewInit. |
I mean, I would like to store only sorting (column names, order etc.) and filtering (column names, operator..) and not current page. But then I don't know how to restore (initialise table) with stored values. |
Thank you. I didn't know that p-table has these properties which I can set manually: I'm using lazyload tables and I can store those values during (onLazyLoad) and restore them in the constructor. |
Hi, 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! |
Describe the bug
At the moment table support only to store state (pagination, sorting, filtering options) to session or local storage.
Would be nice to have possibility to implement custom state save and restore.
Environment
not important
Reproducer
No response
Angular version
17
PrimeNG version
17
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
20
Browser(s)
No response
Steps to reproduce the behavior
No response
Expected behavior
No response
The text was updated successfully, but these errors were encountered: