Skip to main content

DxAccordion.BeforeCollapse Event

Fires when an item is about to be collapsed and allows you to cancel the action.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public Action<AccordionItemCancelEventArgs> BeforeCollapse { get; set; }

Event Data

The BeforeCollapse event's data class is AccordionItemCancelEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Specifies whether the action that raised the event should be canceled.
CausedByAPI Obsolete. Specifies whether an event was triggered by user action or from code. Inherited from AccordionItemStateChangeEventArgs.
ItemInfo Returns information about an item related to the event. Inherited from AccordionItemEventArgs.
Reason Returns the reason why the Accordion item’s expansion state changed. Inherited from AccordionItemStateChangeEventArgs.

Remarks

The code sample below demonstrates how to cancel the collapse action for root-level nodes:

<DxAccordion BeforeCollapse="@BeforeCollapse">
    @* ... *@
</DxAccordion>

@code  {
    void BeforeCollapse(AccordionItemCancelEventArgs args) {
        if (args.ItemInfo.Level == 0) args.Cancel = true;
    }
}
See Also