Saving table preferences

Tags: #<Tag:0x00007f8b23b05f58>

I have a functionality in which i need to save user preferences for the table into some persistent storage.

Let say user has deleted some columns from the table or applied some reordering of columns, i want those settings to be saved, so that when user logins again, the formatting of the table can remain same.

Is there any way to do it?

Welcome @shradhag510

A new dataset you can get on each change (afterChange hook) by calling getData method.

When it comes to columns order, you’d need to get it from the afterColumnMove hook.

Thanks aleksandra.

I do not need to get data set.
The data set will be returned from the server every time.
I just need to save setting like column order, column list, sorting etc. I want to save setting somewhere(like server) and feed those settings to handsontable on page load.

Sorting is saved via persistentState https://handsontable.com/docs/6.2.2/Options.html#persistentState which you can also control over 3 methods: persistentStateLoad, persistentStateReset, persistentStateSave

The persistentState works for sorting and moving columns and rows

Thanks for the response aleksandra.
Is there any way to save column addition and deletion as well?

You can call getData() method then you’d get the complete dataset + you can count number of columns getData()[0].length and number of rows getData().length