Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic column width with handsontable

Tags:

handsontable

I'm using handsontable and my grids are dynamics. I'm creating them by pushing the data from a XML file. So, the content of the columns are always differents and I want that the width of that columns are defined with the content of the existing cells. If the column contains just "Parley", I want a short width and if I have "One Ring to rule them all", the width should increase.

How should I do please ?

EDIT :

I tried to add : autoColumnSize : true and it works at the beginning, but if I enter a value in a cell, every cells are shrinking.

Before :

enter image description here

After :

enter image description here

And this is the options I use to declare my hot :

var hot_itk = new Handsontable(container, {
        data: data_itk,         
        minSpareRows: 1,
        autoColumnSize : true,
        observeChanges : true,
        columnSorting : true,
        rowHeaders: false,
        colHeaders: false,
        contextMenu: true,
        height: 550,
like image 985
Erlaunis Avatar asked Oct 31 '22 21:10

Erlaunis


1 Answers

Have you tried using the stretchH: all option?

var hot_itk = new Handsontable(container, {
    data: data_itk,         
    minSpareRows: 1,
    autoColumnSize : true,
    stretchH: 'all',
    ... 

This stretches the table to the container's width.

like image 194
adriennetacke Avatar answered Jan 04 '23 13:01

adriennetacke