Auto Row/Column Header Resize:

Tags: #<Tag:0x00007f8b19c95b98>

I was wondering how I could configure the table such that all row and column headers take up exactly or more than the necessary width to display the text within. Can anyone suggest a crude JS implementation? Thanks for whatever advice you can give.

Hey @patthebureaucrat

if you do not set colWidths columns expand in width as long as the text is wider than 52px (default width). Unfortunately, those 52px are hardcoded.
You alter the width of the columns programmatically, but there is no option to turn it on/off.

How would I do so programatically as you suggested?

You could search for the longest content in the column (get the array of strings via getDataAtCol) and use colWidths as a methods to set a width for it.

However, you’d need to use the same logic in the afterChange hook by calling the updateSettings > colWidths as well to keep the column width changing accordingly to the content length.

Would get data at col necessarily show me the length of the row headers though? How would I update rowHeader width?

no, it will only return an array of strings. You’d need to create a comparison system to check which one is the longest. Here in SO https://stackoverflow.com/questions/6521245/finding-longest-string-in-array, they’re doing the same job.

How would I update rowHeader width?

You can update any settings via updateSettings method. Here’s a demo https://jsfiddle.net/jgopzb86/