Blazorise DataGrid: Resizing
Adjust the width of columns in the DataGrid to better fit the data.
Overview
With the resizable column feature, users can easily adjust the width of columns in the DataGrid to better fit the data they are viewing. This can be particularly useful when working with large sets of data, where some columns may have longer or shorter data than others. By allowing users to resize columns, they can more easily read and understand the data in the grid.
Examples
Resizable
The resizable column feature is easy to enable in the Blazorise DataGrid. Just define theResizable
and ResizeMode
parameters.
<Field> <FieldLabel> Resize Mode </FieldLabel> <FieldBody> <Select @bind-SelectedValue=""> <SelectItem Value="TableResizeMode.Header">Header</SelectItem> <SelectItem Value="TableResizeMode.Columns">Columns</SelectItem> </Select> </FieldBody> </Field> <DataGrid TItem="Employee" Data="" @bind-SelectedRow="" Responsive Resizable ResizeMode=""> <DataGridCommandColumn /> <DataGridColumn Field="@nameof(Employee.Id)" Caption="#" Sortable="false" /> <DataGridColumn Field="@nameof(Employee.FirstName)" Caption="First Name" Editable /> <DataGridColumn Field="@nameof(Employee.LastName)" Caption="Last Name" Editable /> <DataGridColumn Field="@nameof(Employee.Email)" Caption="Email" Editable /> <DataGridColumn Field="@nameof(Employee.Salary)" Caption="Salary" DisplayFormat="{0:C}" DisplayFormatProvider="@System.Globalization.CultureInfo.GetCultureInfo("fr-FR")" Editable> <EditTemplate> <NumericEdit TValue="decimal" Value="@((decimal)context.CellValue)" ValueChanged="@( v => context.CellValue = v)" /> </EditTemplate> </DataGridColumn> </DataGrid>
@code { [Inject] public EmployeeData EmployeeData { get; set; } private List<Employee> employeeList; private Employee selectedEmployee; private TableResizeMode resizeMode = TableResizeMode.Header; protected override async Task OnInitializedAsync() { employeeList = await EmployeeData.GetDataAsync(); await base.OnInitializedAsync(); } }
API
See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.