ActionList Control
The ActionList control lists a series of actions in the form of buttons.
Personalization
To add actions to the control, you must specify the namespace and class name in the control's CustomControlClass property.
In the InitAsync method , you can add new actions through the native methods of the Control class.
Finally, you must specify the methods to be executed based on the name assigned to the action.
using System;
using System.Threading.Tasks;
using System.Threading;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using DataWeb.Structure;
using DataWeb.Identity;
using DataWeb.Data;
using DataWeb.Data.Controls;
using DataWeb.Web.App.Infrastructure;
namespace DataWeb.Web.App.DataWeb.Data.Controls
{
public class Product_ActionListAreaName(Form form, IServiceProvider serviceProvider) : ActionList(form, serviceProvider)
{
private readonly IStringLocalizer localizer = serviceProvider.GetService<IStringLocalizer>();
private readonly ProductStore productStore = serviceProvider.GetService<ProductStore>();
public override async Task InitAsync(CancellationToken cancellationToken = default)
{
await base.InitAsync(cancellationToken);
AddActionSetNavigation("New item",
[
new() { IdMaster = StructureDefinition.RootIdMaster, SectionName = AppStructureDefinition.SectionDemoAreas, IsHidden = true },
new() { IdMaster = StructureDefinition.VoidIdMaster, SectionName = AppStructureDefinition.SectionDemoAreaData }
]);
AddActionSetNavigation("Open section",
[
new ContextAction.Step{ IdMaster = StructureDefinition.RootIdMaster, SectionName = AppStructureDefinition.SectionDemoAreas }
]);
AddActionSetRemoteAction("Notify status", "NotifyStatus", ContextActionType.Notification, isConfirmRequired: true, isSaveItemBeforeProcess: true, isReloadAfterProcess: true);
AddActionSetRemoteAction("Set product status", "SetProductStatus", ContextActionType.Dialog, dialogFormName: "Form_ActionProductStatus", isConfirmRequired: true, isSaveItemBeforeProcess: true, isReloadAfterProcess: true);
}
public override async Task<ContextAction.Result> ProcessActionAsync(ContextAction action, IUser user, string itemId = null, object value = null, List<Form.ProvidedValue> controlValues = null, NavigationContext navigationContext = null, CancellationToken cancellationToken = default)
{
var result = await base.ProcessActionAsync(action, user, itemId, value, controlValues, navigationContext, cancellationToken);
if (!result.IsValid)
{
return result;
}
switch (action.Name)
{
case "NotifyStatus":
result = await NotifyStatus(itemId);
break;
case "SetProductStatus":
result = await SetProductStatus(itemId);
break;
}
return result;
}
}
}