Access List View Grid Control Settings Using a Controller
- 2 minutes to read
This lesson explains how to access the properties of a grid control displayed within a List View.
In this lesson, you will implement a new View Controller. This controller will change the way the grid control columns are resized.
NOTE
The API used in this tutorial is avalable since v20.2.4.
Before you proceed, take a moment to review the following lesson.
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 control in any List View. The columns are resized with the entire grid control.
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 control properties.
Next Lesson
Place an Action in a Different Location