This is my first message, so be gentle with me please.
I am trying to use handsontable, and it is awesome. But, I am having some troubles about it.
How can I get all columns’ widths?
I am getting all table data with hot.getData(), but I want to get cell’s background color, font size, font color, alignment, etc too. How can I do that? Can I do that?
I know hot.getCellsMeta() function, but this gives me couple of supported class names, that’s all.
Long story short, I want to save the table with all datas, col width, styles, etc. How can I do that?
How can I get all columns’ widths?
You can call the Core getColWidth method. Here’s a demo https://jsfiddle.net/AMBudnik/r31u0jef/ It shows the values even if you resize the columns.
As you can see there’s a need to create a loop for all cells.
I know hot.getCellsMeta() function, but this gives me couple of supported class names, that’s all.
To get more than a class you should use the getCellMeta as the parent object that. Here’s an example https://jsfiddle.net/AMBudnik/bo2d084z/ Unfortunately, we do not have documentation for all the cell meta but most of them are just our options https://handsontable.com/docs/7.2.2/Options.html
Long story short, I want to save the table with all data, col width, styles, etc. How can I do that?
This might be a challenge to make all these loops and keep the performance on a high level so I recommend using hooks. Each of the hooks is triggered by a different behavior so if you could share some scenarios I’ll be happy to help
You can just run getSelected() which checks what are the coordinates of the cell and then pass those + your custom settings to the array of changes.
In Handsontable we’re lacking a method to get every metadata at once to rebuild the table so creating a separate array might be the only way to get those settings back.