Back to Devexpress

DxAccordion.SelectItem(Func<IAccordionItemInfo, Boolean>) Method

blazor-devexpress-dot-blazor-dot-dxaccordion-dot-selectitem-x28-system-dot-func-devexpress-dot-blazor-dot-iaccordioniteminfo-system-dot-boolean-x29.md

latest2.2 KB
Original Source

DxAccordion.SelectItem(Func<IAccordionItemInfo, Boolean>) Method

Selects the specified item.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public void SelectItem(
    Func<IAccordionItemInfo, bool> predicate
)

Parameters

NameTypeDescription
predicateFunc<IAccordionItemInfo, Boolean>

A delegate method that specifies a particular item.

|

Remarks

If item selection is enabled, you can use the SelectItem method to select an item from code. This method does not select the specified item in bound mode if Load Child Items on Demand mode is enabled and the item is not loaded yet. If none of the items meet the specified condition, the component does not clear selection. Call the ClearSelection() method to deselect items.

The following code snippet implements the selection button:

razor
<DxAccordion @ref="MyAccordion" SelectionMode="NavigationSelectionMode.Single">
    <Items>
        <DxAccordionItem Text="Shapes">
            <Items>
                <DxAccordionItem Text="Circle" />
                <DxAccordionItem Text="Square" />
            </Items>
        </DxAccordionItem>
        <DxAccordionItem Text="Templates" />
    </Items>
</DxAccordion>

<DxButton Click="@OnClick">Select item</DxButton>

@code {
    DxAccordion MyAccordion;
    void OnClick() => MyAccordion.SelectItem(x => x.Text == "Templates");
}

See Also

DxAccordion Class

DxAccordion Members

DevExpress.Blazor Namespace