Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handsontable, colWidths: function: how to set a column width fitting content?

My aim is to set the first column's width equal to a certain number and leave other columns' widths untouched. Now I know that setting

colWidths: [myValue]

actually breaks other columns' widths but this seems to be workaroundable using

colWidths: function(index) {
    if(index == 0)
        return myValue;
    return ???
}

but I wonder what should I return in the place of ???? undefined doesn't work (well, it works in the same fashion as colWidths: [myValue] – every other column gets the same default width). How do I get the "width by content" value for this?

like image 558
YakovL Avatar asked Dec 23 '22 16:12

YakovL


1 Answers

Use the option manualColumnResize instead of colWidths but the same way as in your question (only defining the first column witdh) :

manualColumnResize: [myValue]

The first column width will be define as your value, the other columns will still be dynamic. (Because of autoColumnSizeObject set to true by default, which is also changed to false when you use colWidths option).

You can find a working example here.

like image 176
Fab Avatar answered May 04 '23 10:05

Fab