Blazorise DataGrid: Columns
DataGrid provides many types of columns. You can use built-in columns such as text, numeric, date, checkbox, select, etc to automatically create specialized content.
DataGridColumn
Default column template for text editor<DataGrid TItem="Employee" Data="" PageSize="5" Responsive Editable Filterable> <DataGridColumn Field="@nameof(Employee.Email)" Caption="Email" Editable /> <DataGridCommandColumn /> </DataGrid>
@code { [Inject] public EmployeeData EmployeeData { get; set; } private List<Employee> employeeList; protected override async Task OnInitializedAsync() { employeeList = await EmployeeData.GetDataAsync(); await base.OnInitializedAsync(); } }
DataGridCheckColumn
Column template for boolean values<DataGrid TItem="Employee" Data="" PageSize="5" Responsive Editable Filterable> <DataGridCheckColumn Field="@nameof(Employee.IsActive)" Caption="Active" Editable /> <DataGridCommandColumn /> </DataGrid>
@code { [Inject] public EmployeeData EmployeeData { get; set; } private List<Employee> employeeList; protected override async Task OnInitializedAsync() { employeeList = await EmployeeData.GetDataAsync(); await base.OnInitializedAsync(); } }
DataGridDateColumn
Column template for datetime values<DataGrid TItem="Employee" Data="" PageSize="5" Responsive Editable Filterable> <DataGridDateColumn Field="@nameof(Employee.DateOfBirth)" Caption="Date Of Birth" Editable /> <DataGridCommandColumn /> </DataGrid>
@code { [Inject] public EmployeeData EmployeeData { get; set; } private List<Employee> employeeList; protected override async Task OnInitializedAsync() { employeeList = await EmployeeData.GetDataAsync(); await base.OnInitializedAsync(); } }
DataGridNumericColumn
Column template for numeric values<DataGrid TItem="Employee" Data="" PageSize="5" Responsive Editable Filterable> <DataGridNumericColumn Field="@nameof(Employee.Salary)" Caption="Salary" Editable /> <DataGridCommandColumn /> </DataGrid>
@code { [Inject] public EmployeeData EmployeeData { get; set; } private List<Employee> employeeList; protected override async Task OnInitializedAsync() { employeeList = await EmployeeData.GetDataAsync(); await base.OnInitializedAsync(); } }
DataGridSelectColumn
Column template for selectable values<DataGrid TItem="Employee" Data="" PageSize="5" Responsive Editable Filterable> <DataGridSelectColumn TItem="Employee" Field="@nameof( Employee.Gender )" Caption="Gender" Editable Data="EmployeeData.Genders" ValueField="(x) => ((Gender)x).Code" TextField="(x) => ((Gender)x).Description" /> <DataGridCommandColumn /> </DataGrid>
@code { [Inject] public EmployeeData EmployeeData { get; set; } private List<Employee> employeeList; 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.