Save table style

Tags: #<Tag:0x00007f0b08fc4eb8>

Hi, if I operate on the form, such as merge cells or stretch the height of rows and the width of columns, how should I save the style so that the table uses the last style when I open it next time ?

Hey @759603225

For some changes, you can use the persistentState

Turns on saving the state of column sorting, column positions and column sizes in local storage.

For the rest, you’d need to track the behavior with hooks

If I want to save to the server and then get the table style when the other computer opens the form, how to get these information from local storage

With styling, it is a bit different. How the styles are added? Is it

  • a default set o styles
  • styling based on value
  • added via button
  • added via context/dropdown menu?

Additionally, when you want to store it

  • on a button click
  • with some interval

I am still not clear. Can you provide a demo?

I need some more information about the requirements (if they are confidential I propose to switch to emails - support@handsontable.com). Only then I will be able to share some examples as each requirement (from the list above) can be approached with a different code.

Here are some requirement, when I change the size of columns and rows, I want to record their coordinate as well as the width or height in order to save the data to the database, and is there a way to save the style of the cell, such as font size, color, background color, text-align, etc?

Hey @759603225

the persistentStateSave hook will share all the needed information when you change the order of rows/columns, change their size or sort them. Here you can test it https://jsfiddle.net/handsoncode/y08vbgsL/ (data is logged in the console).

When it comes to the styling I need more information, (like mentioned 2 comments above).

With styling, it is a bit different. How the styles are added? Is it

  • a default set o styles
  • styling based on value
  • added via button
  • added via context/dropdown menu?

Additionally, when you want to store it

  • on a button click
  • with some interval

ok, I will try it , thanks