DxGridListEditor.GridInstance Property
Provides access to methods of the DxGrid control.
Namespace: DevExpress.ExpressApp.Blazor.Editors
Assembly: DevExpress.ExpressApp.Blazor.v25.1.dll
NuGet Package: DevExpress.ExpressApp.Blazor
Declaration
Property Value
Type | Description |
---|---|
IGrid | An |
Remarks
Use the GridInstance
property to call methods of the grid control. To change grid properties, use GridModel
.
The DxGrid
instance becomes available after it is rendered. Always check that GridInstance
is not null.
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Blazor.Editors;
namespace MySolution.Blazor.Server.Controllers;
public class TestController : ViewController<ListView> {
public TestController() {
SimpleAction simpleAction = new SimpleAction(this, "Test Action", DevExpress.Persistent.Base.PredefinedCategory.Edit);
simpleAction.Execute += (s, e) => {
if(View.Editor is DxGridListEditor editor) {
// Always check that GridInstance is not `null`.
editor.GridInstance?.CollapseAllGroupRows();
}
};
}
}
The following code sample uses the GridComponentCaptured event to access DxGrid
API:
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Editors;
namespace MySolution.Blazor.Server.Controllers;
public class TestController : ViewController<ListView> {
protected override void OnViewControlsCreated() {
base.OnViewControlsCreated();
if(View.Editor is DxGridListEditor editor) {
editor.GridComponentCaptured += (s, e) => {
e.Grid.CollapseAllGroupRows();
};
}
}
}
Note
Do not cache the grid instance in controller fields because the grid can be disposed of and then rendered again when a user navigates the XAF application. Handle the GridComponentCaptured event every time you access the grid instance.