Access List View Grid Component Settings Using a Controller (.NET 5)
- 2 minutes to read
This lesson explains how to access the properties of a grid component displayed within a List View.
In this lesson, you will implement a new View Controller. This controller will change the way the grid component columns are resized.
Step-by-Step Instructions
- In MySolution.Module.Blazor, add a View Controller to the Controllers folder, as described in the Add a Simple Action lesson. Name it “ColumnResizeModeViewController“.
Derive the new controller from the
ViewController<ListView>
and override the OnViewControlsCreated method as follows.using DevExpress.Blazor; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Blazor.Editors.Grid; namespace MySolution.Module.Blazor.Controllers { public partial class ColumnResizeModeViewController : ViewController<ListView> { public ColumnResizeModeViewController() { InitializeComponent(); } // ... protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); if(View.Editor is GridListEditor gridListEditor) { IDxDataGridAdapter dataGridAdapter = gridListEditor.GetDataGridAdapter(); dataGridAdapter.DataGridModel.ColumnResizeMode = DataGridColumnResizeMode.Component; } } // ... } }
Run the application. Try to resize any columns in grid component in any List View. The columns are resized with the entire grid component.
Detailed Explanation
The List View editor exposes the GetDataGridAdapter() method that returns the Component Adapter.
Use the Component Adapter‘s DataGridModel
property to access the grid component properties.
Next Lesson
Place an Action in a Different Location
See Also