All docs
V21.2
21.2
21.1
20.2
20.1
The page you are viewing does not exist in version 20.1.
19.2
The page you are viewing does not exist in version 19.2.
19.1
The page you are viewing does not exist in version 19.1.
18.2
The page you are viewing does not exist in version 18.2.
18.1
The page you are viewing does not exist in version 18.1.
17.2
The page you are viewing does not exist in version 17.2.

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.

Note

The API used in this tutorial is available since v20.2.4.

Before you proceed, take a moment to review the following lesson:

Step-by-Step Instructions

  1. In MySolution.Module.Blazor, add a View Controller to the Controllers folder, as described in the Add a Simple Action lesson. Name it “ColumnResizeModeViewController“.
  2. 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;
                }
            }
            // ...
        }
    }
    
  3. Run the application. Try to resize any columns in grid component in any List View. The columns are resized with the entire grid component.

    xaf ASP.NET Core Blazor access grid properties resize|

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