olifolkerd / tabulator

Interactive Tables and Data Grids for JavaScript
http://tabulator.info
MIT License
6.76k stars 821 forks source link

layoutColumnsOnNewData:true should resize columns when adding new row #4589

Open jakovpucekovic opened 1 month ago

jakovpucekovic commented 1 month ago

Is your feature request related to a problem? Please describe. I have a table with layoutColumnsOnNewData:true which is loaded with some data. When I add a new row to the table, the columns don't resize automatically. If the new data is longer than the data already present in the column, the new data is cut of with an ellipsis (...). From the documentation (https://tabulator.info/docs/6.3/layout#layoutcolumnsonnewdata) I assumed that column widths would adjust every time data was added into the table, not just when using setData.

Describe the solution you'd like If layoutColumnsOnNewData is set to true the table should check and resize columns if a new data is added via the addRow function.

Describe alternatives you've considered Currently I'm calling setWidth(true) on all columns, after adding a row.

table.addRow({ name: "long_string_123456789"}).then(() => table.getColumns().forEach(col => col.setWidth(true)));

Additional context Example: https://jsfiddle.net/tguh8m3e/