# Search Panel

The Grid component has built-in search functionality that you can use through either the SmartBox Search mode or the Search Panel in the toolbar. Both options rely on Grid filtering to show only the relevant records.

## SmartBox Search

The Grid search functionality is available in the [AI Smart Box](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/grid/smart-grid/ai-toolbar-tool). The Smart Box Search mode uses the same Grid `Search` configuration, including `Search.fields` and field operators.

To enable it, add the Smart Box tool to the Grid toolbar and configure the `SmartBox.SearchSettings` option.

```Razor HtmlHelper
    @(Html.Kendo().Grid<CustomerViewModel>()
        .Name("grid")
        .ToolBar(toolbar => toolbar.SmartBox())
        .Search(search =>
        {
            search.Field(c => c.ContactName, "contains");
            search.Field(c => c.Age, "eq");
        })
        .SmartBox(sb => sb
            .ActiveMode(SmartBoxActiveMode.Search)
            .SearchSettings(s => s.Enabled(true))
        )
        ...
    )
```

```Razor TagHelper
    <kendo-grid name="grid">
        <toolbar>
            <toolbar-button name="smartBox"></toolbar-button>
        </toolbar>
        <search fields-extended="@(new object[]
        {
            new { Name = "ContactName", Operator = "contains" },
            new { Name = "Age", Operator = "eq" }
        })">
        </search>
        <smart-box active-mode="SmartBoxActiveMode.Search">
            <search-settings enabled="true"></search-settings>
        </smart-box>
        ...
    </kendo-grid>
```

For additional Smart Box search capabilities, such as Semantic Search mode, refer to [Semantic Search](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/grid/smart-grid/semantic-search).

## Search Panel

> Search Panel functionality is available as of [Kendo UI R3 2019](https://www.telerik.com/support/whats-new/kendo-ui/release-history/kendo-ui-r3-2019) release.

### Getting Started

To enable the functionality, include the `Search` option in the toolbar configuration.

You can also customize which fields are searched when users enter a value in the search input.

```Razor HtmlHelper
    @(Html.Kendo().Grid<CustomerViewModel>()
        .Name("grid")
        .ToolBar(t => t.Search())
        .Search(s =>
        {
            s.Field(c => c.ContactTitle);
        })
        ...
    )
```

```Razor TagHelper
    <kendo-grid name="grid">
        <toolbar>
            <toolbar-button name="search"></toolbar-button>
        </toolbar>
        <search fields="@(new string[] { "ContactTitle" })"></search>
        ...
    </kendo-grid>
```

## Specify the Filter Operator

As of Kendo UI 2021 R3 SP1, you can specify filter operators for each filter type. With this update, you can filter non-string types.

The following example demonstrates how to specify which fields to include in the search.

```Razor HtmlHelper
    @(Html.Kendo().Grid<CustomerViewModel>()
        .Name("grid")
        .ToolBar(t => t.Search())
        .Search(s =>
        {
            s.Field(c => c.ContactName);
            s.Field(c => c.Age);
        })
        ...
    )
```

```Razor TagHelper
    <kendo-grid name="grid">
        <toolbar>
            <toolbar-button name="search"></toolbar-button>
        </toolbar>
        <search fields="@(new string[] { "ContactName", "Age" })"></search>
        ...
    </kendo-grid>
```

The following example demonstrates how to specify the operator for the field that will be used in the filter expression.

```Razor HtmlHelper
    @(Html.Kendo().Grid<CustomerViewModel>()
        .Name("grid")
        .ToolBar(t => t.Search())
        .Search(s =>
        {
            s.Field(c => c.ContactName, "contains");
            s.Field(c => c.Age, "eq");
        })
        ...
    )
```

```Razor TagHelper
    <kendo-grid name="grid">
        <toolbar>
            <toolbar-button name="search"></toolbar-button>
        </toolbar>
        <search fields-extended="@(new object[]
        {
            new { Name = "ContactName", Operator = "contains" },
            new { Name = "Age", Operator = "eq" }
        })">
        </search>
        ...
    </kendo-grid>
```

## Known Limitations

* When filtering is enabled, the filter textboxes for all Grid columns will be populated with the value entered in the search textbox.

## Troubleshoot Filter Parsing Exceptions

If a Grid search request throws an `InvalidCastException` involving `CompositeFilterDescriptor` and `FilterDescriptor`, inspect the server-side stack trace. If it includes `FilterNodeVisitor.Visit(PropertyNode)`, `FilterDescriptorFactory.Create`, and `DataSourceRequestModelBinder.CreateDataSourceRequest`, the failure occurs during filter parsing.

The `DataSourceRequest` model binder parses the incoming filter before the controller action executes. Changing `ToDataSourceResult(request)` or traversing `request.Filters` inside that action cannot resolve an exception thrown during model binding. Composite filters are supported; their presence alone does not establish the cause.

To investigate the failing request:

1. Use the browser's network tools to capture the request's serialized `filter` parameter and the search text that triggers the exception.
2. Record the Grid's `Search` fields, operators, DataSource configuration, and any custom `parameterMap` logic.
3. Record the deployed Telerik UI NuGet package and Kendo UI script versions. Verify that they match, as required by the [installation guidance](https://www.telerik.com/aspnet-core-ui/documentation/installation/activating-your-license/setting-up-your-license).
4. If the exception persists, provide Telerik Support with a minimal reproduction, the stack trace, and the captured configuration and request. Remove sensitive data before sharing these details.

The stack trace identifies the failure stage, but does not establish a specific cause or a version-specific fix.

## See Also

* [Search Panel in the Telerik UI Grid (Demo)](https://demos.telerik.com/aspnet-core/grid/search-panel)

* [ASP.NET Core DataGrid Homepage](https://www.telerik.com/aspnet-core-ui/grid)

* [Server-Side API](https://www.telerik.com/aspnet-core-ui/documentation/api/grid)

* [AI Smart Box](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/grid/smart-grid/ai-toolbar-tool)

* [Smart Grid Overview](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/data-management/grid/smart-grid)

* [Knowledge Base Section](https://www.telerik.com/aspnet-core-ui/documentation/knowledge-base)
