Access the Grid Component in a List View (.NET 6)
This lesson explains how to access the properties of a grid component displayed within a List View.
The instructions below describe the implementation of a new View Controller. This controller enables operations to resize columns.
Step-by-Step Instructions
- In the MySolution.Blazor.Server project, add a View Controller to the Controllers folder. Name this controller ColumnResizeModeViewController.
Specify the controller’s ancestor class
ViewController<ListView>
and override theOnViewControlsCreated
method:using DevExpress.ExpressApp; using DevExpress.ExpressApp.Blazor.Editors; namespace MySolution.Blazor.Server.Controllers { public partial class ColumnResizeModeViewController : ViewController<ListView> { public ColumnResizeModeViewController() { InitializeComponent(); } // ... protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); if (View.Editor is DxGridListEditor gridListEditor) { //Obtain the Component Adapter IDxGridAdapter dataGridAdapter = gridListEditor.GetGridAdapter(); //Access grid component properties and specify how exactly a user can resize columns dataGridAdapter.GridModel.ColumnResizeMode = DevExpress.Blazor.GridColumnResizeMode.ColumnsContainer; } } // ... } }
Run the application. Try to resize a column in a grid component in any List View. The width of the grid container changes, while the other columns retain their width.
Next Lesson
Place an Action in a Different Location
See Also