Back to Devexpress

DxDropDownBox.DropDownFooterTemplate Property

blazor-devexpress-dot-blazor-dot-dxdropdownbox-6afaf967.md

latest3.7 KB
Original Source

DxDropDownBox.DropDownFooterTemplate Property

Specifies a template for the drop-down window’s footer.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public RenderFragment<DropDownBoxTemplateContext> DropDownFooterTemplate { get; set; }

Property Value

TypeDescription
RenderFragment<DropDownBoxTemplateContext>

The footer template.

|

Remarks

The drop-down window can include a header, body, and footer. Use the DropDownFooterTemplate property to specify the content for the window’s footer element.

DropDownFooterTemplate has the context parameter. You can use the parameter’s DropDownBox property to get information about the processed editor.

razor
@inject NwindDataService NwindDataService

<DxDropDownBox @bind-Value="Value"
                QueryDisplayText="QueryText"
                CssClass="ddBox">
    <DropDownHeaderTemplate>
        <span class="oi oi-person" />
        Select Employees:
    </DropDownHeaderTemplate>
    <DropDownBodyTemplate>
        <DxListBox @ref="listBox" 
                    Data="@ListBoxData" TData="Employee" TValue="Employee"
                    Values="@(GetListBoxValues(context.DropDownBox))"
                    TextFieldName="@nameof(Employee.Text)"
                    SelectionMode="ListBoxSelectionMode.Multiple"
                    ShowCheckboxes="true"
                    CssClass="templateListbox"/>
    </DropDownBodyTemplate>
    <DropDownFooterTemplate>
        <DxButton Text="OK" CssClass="btn-margin"
                  Click="@(() => SetDropDownBoxValue(context.DropDownBox))" />
        <DxButton Text="Cancel" RenderStyle="ButtonRenderStyle.Secondary"
                  Click="@(() => context.DropDownBox.HideDropDown())" />
    </DropDownFooterTemplate>
</DxDropDownBox>

@code {
    DxListBox<Employee, Employee> listBox;
    IEnumerable<Employee> ListBoxData { get; set; }
    object Value { get; set; }

    string QueryText(DropDownBoxQueryDisplayTextContext arg) {
        var names = (arg.Value as IEnumerable<Employee>)?.Select(x => x.LastName);
        return names != null ? string.Join(",", names) : string.Empty;
    }

    IEnumerable<Employee> GetListBoxValues(IDropDownBox dropDownBox) {
        return dropDownBox.Value as IEnumerable<Employee>;
    }

    void SetDropDownBoxValue(IDropDownBox dropDownBox) {
        dropDownBox.BeginUpdate();
        dropDownBox.Value = listBox.Values;
        dropDownBox.HideDropDown();
        dropDownBox.EndUpdate();
    }

    protected override async Task OnInitializedAsync() {
        ListBoxData = await NwindDataService.GetEmployeesAsync();
        Value = ListBoxData.Take(2);
    }
}
css
.templateListbox {
    --dxbl-list-box-border-width: 0px;
    width: 100%
}
.ddBox {
    max-width: 480px;
    width: 100%;
}
.btn-margin {
    margin-right: 8px;
}

Implements

DropDownFooterTemplate

See Also

DxDropDownBox Class

DxDropDownBox Members

DevExpress.Blazor Namespace