Skip to main content
A newer version of this page is available. .
All docs
V22.1

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.

Note

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

Step-by-Step Instructions

  1. In the MySolution.Blazor.Server project, add a View Controller to the Controllers folder. Name this controller ColumnResizeModeViewController.
  2. Specify the controller’s ancestor class ViewController<ListView> and override the OnViewControlsCreated 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;
                }
            }
            // ...
        }
    }
    
  3. 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.

    XAF ASP.NET Core Blazor access grid properties resize|

Next Lesson

Place an Action in a Different Location

See Also