Configuration searchPanel

Specifies options of the search panel.

Type: Object

A search panel is a grid element that allows the user to search grid records by a search string. Searching performs in those grid columns that have the allowFiltering option set to true.

Note that searching is performed differently in columns with different data types. To find a record by a numeric, boolean or date value, a user must enter the full value into the search panel. To find a record by a string value, entering a part of this value is sufficient.

The search panel is located in the upper-right corner of the dxDataGrid widget. To make it visible, set the visible property of the searchPanel configuration object to true.

If at least one grid record matches a search string, this string is highlighted in the located record. To disable this feature, assign false to the highlightSearchText property. Additionally, you can specify the width of the search panel and the text displayed in it when it is empty using the width and placeholder options respectively.

Also, you can search grid records by a search string from code. Call the searchByText(text) method to do this.

Show Example:
jQuery

In this example, the search panel is made visible using the visible option of the searchPanel object. Additionally, its width is changed using the width option of the same object.

<div id="gridContainer" style="height:380px; max-width:800px; margin: 0 auto"></div>
$(function () {
    $("#gridContainer").dxDataGrid({
        dataSource: orders,
        columns: [
            'OrderID', 'CustomerID',
            { dataField: 'OrderDate', dataType: 'date' },
            { dataField: 'ShippedDate', dataType: 'date' },
            'ShipName',
            { dataField: 'ShipCountry', caption: 'Ship To' }
        ],
        paging: { pageSize: 7 },
        searchPanel: {
            visible: true,
            width: 250
        }
    });
});

highlightSearchText

Specifies whether or not search strings in the located grid records should be highlighted.

Type: Boolean
Default Value: true

Show Example:
jQuery

In this example, you can change the value of the searchPanel | highlightSearchText option using the check box under the grid. Type something in the search panel and see the changes.

<div id="gridContainer" style="height:380px; max-width:800px; margin: 0 auto"></div>
<div id="checkboxContainer" style="height:20px;margin:5px auto;text-align:center">
    <input type="checkbox" id="highlightSearchTextCheckbox" checked> Highlight Search Text
</div>
$(function () {
    $("#gridContainer").dxDataGrid({
        dataSource: orders,
        columns: [
            'OrderID', 'CustomerID',
            { dataField: 'OrderDate', dataType: 'date' },
            { dataField: 'ShippedDate', dataType: 'date' },
            'ShipName',
            { dataField: 'ShipCountry', caption: 'Ship To' }
        ],
        paging: { pageSize: 7 },
        searchPanel: {
            visible: true,
            highlightSearchText: true
        }
    });

    $('#highlightSearchTextCheckbox').change(function () {
        var dataGrid = $('#gridContainer').dxDataGrid('instance');
        dataGrid.option({
            searchPanel: { highlightSearchText: this.checked }
        });
        dataGrid.repaint();
    });
});

placeholder

Specifies text displayed by the search panel when no search string was typed.

Type: String
Default Value: 'Search...'

Show Example:
jQuery

In this example, the text displayed by an empty search panel is changed using the searchPanel | placeholder option.

<div id="gridContainer" style="height:380px; max-width:800px; margin: 0 auto"></div>
$(function () {
    $("#gridContainer").dxDataGrid({
        dataSource: orders,
        columns: [
            'OrderID', 'CustomerID',
            { dataField: 'OrderDate', dataType: 'date' },
            { dataField: 'ShippedDate', dataType: 'date' },
            'ShipName',
            { dataField: 'ShipCountry', caption: 'Ship To' }
        ],
        paging: { pageSize: 7 },
        searchPanel: {
            visible: true,
            width: 250,
            placeholder: 'Type something here...'
        }
    });
});

visible

Specifies whether the search panel is visible or not.

Type: Boolean
Default Value: false

Show Example:
jQuery

In this example, you can change the visibility of the search panel at runtime using the check box located below the grid.

<div id="gridContainer" style="height:380px; max-width:800px; margin: 0 auto"></div>
<div id="checkboxContainer" style="height:20px;margin:5px auto;text-align:center">
    <input type="checkbox" id="showSearchPanelCheckbox" checked> Show Search Panel
</div>
$(function () {
    $("#gridContainer").dxDataGrid({
        dataSource: orders,
        columns: [
            'OrderID', 'CustomerID',
            { dataField: 'OrderDate', dataType: 'date' },
            { dataField: 'ShippedDate', dataType: 'date' },
            'ShipName',
            { dataField: 'ShipCountry', caption: 'Ship To' }
        ],
        paging: { pageSize: 7 },
        searchPanel: { visible: true }
    });

    $('#showSearchPanelCheckbox').change(function () {
        var dataGrid = $('#gridContainer').dxDataGrid('instance');
        dataGrid.option({
            searchPanel: { visible: this.checked }
        });
        dataGrid.repaint();
    });
});

width

Specifies the width of the search panel in pixels.

Type: Number
Default Value: 160

Show Example:
jQuery

In this example, the width of the search panel is changed using the searchPanel | width option.

<div id="gridContainer" style="height:380px; max-width:800px; margin: 0 auto"></div>
$(function () {
    $("#gridContainer").dxDataGrid({
        dataSource: orders,
        columns: [
            'OrderID', 'CustomerID',
            { dataField: 'OrderDate', dataType: 'date' },
            { dataField: 'ShippedDate', dataType: 'date' },
            'ShipName',
            { dataField: 'ShipCountry', caption: 'Ship To' }
        ],
        paging: { pageSize: 7 },
        searchPanel: {
            visible: true,
            width: 250
        }
    });
});