Back to Devexpress

DxDropDownBox.NullText Property

blazor-devexpress-dot-blazor-dot-dxdropdownbox-dcea81a6.md

latest3.1 KB
Original Source

DxDropDownBox.NullText Property

Specifies the prompt text displayed in the editor when its value is null.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(null)]
[Parameter]
public string NullText { get; set; }

Property Value

TypeDefaultDescription
Stringnull

The prompt text.

|

Remarks

The DxDropDownBox‘s input element is read-only for users. Use the Value property to assign an editor value programmatically and implement the QueryDisplayText function to define how the editor value is displayed in the input element.

Use the NullText property to display prompt text in the editor when Value is null.

Run Demo: DropDown Box - Multiple Selection ListBox

razor
<DxDropDownBox @bind-Value="Value" 
               QueryDisplayText="QueryText" 
               NullText="Select values" 
               ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto">
    <DropDownBodyTemplate>
        <DxListBox Data="@ListBoxData" TData="Employee" TValue="Employee"
                    Values="@(GetListBoxValues(context.DropDownBox))"
                    ValuesChanged="@(values => ListBoxValuesChanged(values, context.DropDownBox))"
                    TextFieldName="@nameof(Employee.Text)"
                    SelectionMode="ListBoxSelectionMode.Multiple"
                    ShowCheckboxes="true"
                    CssClass="templateListbox"
                    SizeMode="Params.SizeMode">
        </DxListBox>
    </DropDownBodyTemplate>
</DxDropDownBox>

@code {
    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 ListBoxValuesChanged(IEnumerable<Employee> values, IDropDownBox dropDownBox) {
        dropDownBox.BeginUpdate();
        dropDownBox.Value = values;
        dropDownBox.EndUpdate();
    }

    protected override async Task OnInitializedAsync() {
        ListBoxData = await NwindDataService.GetEmployeesAsync();
    }
}

Implements

NullText

See Also

DxDropDownBox Class

DxDropDownBox Members

DevExpress.Blazor Namespace