DataGrid - Autosize columns

Auto-Size columns

If the columns are resizable either at the grid level or at the column level (via the columns.resibale prop), then the column sizing can be done using one of two ways. One way to resize columns is from context menu of the column, choosing the desired option for auto sizing, and the other way is to call several methods from grid reference of the computed props (see handle prop).
Note that in order for auto sizing columns to work, you must set enableColumnAutosize to true.
There are several methods which can be used for auto sizing columns. One of them is setColumnSizesToFit method, which sizes columns to fit the available width of the grid.
In order for columns to auto-size, so that the entire content of the column is displayed, you can use setColumnsSizesAuto method. This method has two optional parameters: columnIds which is an array of the columns ids and a boolean skipHeader. If the skipHeader flag is false, the header width is included in computation of the column size, but if you want to skip the header widh, you can pass skipHeader set to true.
If you want to auto-size a specific column, you can do it calling setColumnSizeAuto method passing a required argument which is the id of the column to be resized and an optional argument, skipHeader, which does the same thing as the method presented above.
The skipHeader flag can be set at the grid level via skipHeaderOnAutoSize prop.
Top