Example of AutoFit and Resizing in Blazor DataGrid Component

DataGrid / Columns / AutoFit and Resizing

This sample demonstrates how the DataGrid renders columns with a specified width and how to use the column resizing feature. To resize a column, click and drag the right edge of the column header.

By default, if the total width of the columns is less than the DataGrid width, the columns will automatically expand to fill the available space. Setting the DataGrid AutoFit feature to  true ensures that columns do not exceed their specified width.

Columns in the Blazor DataGrid can be resized by clicking and dragging the right corner of the column header. Set the AllowResizing property to true to enable column resizing. You can also prevent a specific column from being resized by setting the AllowResizing property to false in the column definition. Furthermore, when the right corner of a column header is right clicked, the AutoFitColumnsAsync method will automatically adjust the column width.

The resizing feature has been enabled in this demo by setting the AllowResizing property to true. The Order ID column can be resized between the range of MinWidth of 120px and MaxWidth of 300px. Column resizing has also been disabled for the Shipped Date column.

More information about the column Resizing feature can be found in the documentation section.

Transform your Blazor web apps today with Syncfusion® Blazor components
100+ high-performance and responsive UI components
Dedicated support
Hassle-free licensing
TRY IT FOR FREE