expressappframework-404559-ui-construction-controllers-and-actions-actions-how-to-add-a-grid-column-with-an-action.md
This topic explains how to add an inline Action to a List View’s grid in an XAF ASP.NET Core Blazor application.
This functionality has the following limitations:
Edit, RecordEdit, or ListView.Note
For the purposes of this topic, you can use the MainDemo.NET (ASP.NET Core Blazor) application installed as a part of the XAF package. The default location of the application is %PUBLIC%\Documents\DevExpress Demos 25.2\Components\XAF.
The instructions below explain how to add an Action to the Employee List View grid. The Action opens the selected Employee object’s Detail View in a pop-up window.
Navigate to the MainDemo.Module\Controllers folder. Create a new View Controller and name it ShowPopupViewController.
Replace the auto-generated code with the following code snippet:
Rebuild the project and run the application. Navigate to the Employee List View. Click the Action’s icon in a grid row.
ASP.NET Core Blazor
The instructions below explain how use a method of an entity class and ActionAttribute to add an Action to the Task List View grid.
In ASP.NET Core Blazor application, when a user clicks the Action, the status of the selected Task object changes to Completed.
Navigate to the MainDemo.Module\BusinessObjects folder and open the Task.cs file.
Add the MarkCompleted method to the class:
Rebuild the project and run the application. Navigate to the Task List View and click the Action’s icon in a grid row.
ASP.NET Core Blazor
The code sample below demonstrates how to change the tooltip message of inline Actions. Actions are embedded in a List View (grid control) that displays Task objects.
Cast the CustomizeControlEventsArgs.Control object to ListEditorInlineActionControl and handle its CustomizeInlineActionButton event:
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Editors.ActionControls;
using DevExpress.ExpressApp.SystemModule;
using MainDemo.Module.BusinessObjects;
namespace MainDemo.Blazor.Server.Controllers {
public class CustomizeInlineActionController : ObjectViewController<ListView, DemoTask> {
private void Action_CustomizeControl(object sender, DevExpress.ExpressApp.Actions.CustomizeControlEventArgs e) {
if (e.Control is ListEditorInlineActionControl control) {
control.CustomizeInlineActionButton += Control_CustomizeInlineActionButton;
}
}
private void Control_CustomizeInlineActionButton(object sender, DevExpress.ExpressApp.Blazor.Components.CustomizeInlineActionButtonEventArgs e) {
if (e.DataItem is DemoTask task) {
e.Tooltip = $"Change the status '{task.Status}' to 'Completed'";
}
}
protected override void OnFrameAssigned() {
base.OnFrameAssigned();
var objectMethodController = Frame.GetController<ObjectMethodActionsViewController>();
if (objectMethodController != null) {
var action = objectMethodController.Actions.FirstOrDefault(s => s.Id == "Task.MarkCompleted");
if (action != null) {
action.CustomizeControl += Action_CustomizeControl;
}
}
}
}
}