Skip to main content

GridSearchBoxTemplateContext.SearchText Property

Specifies the search text.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public string SearchText { get; set; }

Property Value

Type Description
String

The search text.

Remarks

When the ShowSearchBox property is set to true, the Grid displays the search box. Users can type text in the box editor to filter and highlight data.

The SearchBoxTemplate property allows you to specify custom content for the search box. In the template, use the context parameter to access the SearchText property, which specifies the search text.

The example below demonstrates how to use the DxSpinEdit<T> component to search for numbers in the Grid.

<DxGrid Data="Products" ShowSearchBox="true">
    <Columns>
        <DxGridDataColumn FieldName="ProductName" />
        <DxGridDataColumn FieldName="CategoryId" Caption="Category" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c" />
    </Columns>
    <SearchBoxTemplate> 
        <DxSpinEdit Value="GetSpinEditValue(context.SearchText)"
                    ValueChanged="(int? v) => context.SearchText = v.ToString()"
                    ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto" />
    </SearchBoxTemplate>
</DxGrid>
@code {
    int? GetSpinEditValue(string searchText) {
        if(string.IsNullOrEmpty(searchText))
            return null;
        return Convert.ToInt32(searchText);
    }
}

Search Box Template

For more information about search in the Grid component, refer to the following topic: Search Box in Blazor Grid.

See Also