DataGrid / Columns / AutoFit and Resizing

Blazor DataGrid Example - Column Resizing and AutoFit

Loading Syncfusion Blazor Server Demos…

This sample demonstrates the DataGrid column resizing feature and how columns are rendered with specified widths.

Columns in the Blazor DataGrid can be resized by clicking and dragging the right corner of the column header. To enable column resizing, set the AllowResizing property to true. You can prevent a specific column from being resized by setting AllowResizing to false in the column definition.

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

When you right-click the right corner of a column header, the AutoFitColumnsAsync method automatically adjusts the column width to fit the content.

In this demo, column resizing is enabled with the following constraints:

  • The Order ID column can be resized between MinWidth of 120px and MaxWidth of 300px.
  • Resizing is disabled for the Shipped Date column.

For more detailed information about column resizing, refer to the column resizing documentation.

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