All docs
V24.2
24.2
24.1
23.2
23.1
22.2
22.1
21.2
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2.
19.1
The page you are viewing does not exist in version 19.1.
18.2
The page you are viewing does not exist in version 18.2.
18.1
The page you are viewing does not exist in version 18.1.
17.2
The page you are viewing does not exist in version 17.2.

JavaScript/jQuery List - Searching

NOTE
Searching works when inputting a plain data structure only. However, if you need the searching capability and grouped data, transform the plain data using the DataSource's group property.

Searching is disabled in the List UI component by default. Assign true to the searchEnabled property to display the search panel. The searchExpr property specifies which data fields should be searched. Assign an array of field names to it if you need to search several fields.

jQuery
JavaScript
const listData = [
    { id: 1, country: "Afghanistan", capital: "Kabul" },
    { id: 2, country: "Albania", capital: "Tirana" },
    // ...
];

$(function() {
    $("#listContainer").dxList({
        dataSource: listData,
        searchEnabled: true,
        searchExpr: ['country', 'capital'],
        itemTemplate: function(data) {
            return $("<div>").text(data.capital + " (" + data.country + ")");
        }
    });
});
Angular
HTML
TypeScript
<dx-list
    [dataSource]="listData"
    [searchEnabled]="true"
    [searchExpr]="['country', 'capital']"
    itemTemplate="listItem">
    <div *dxTemplate="let item of 'listItem'">
        <div>{{item.capital}} ({{item.country}})</div>
    </div>
</dx-list>
import { DxListModule } from "devextreme-angular";
// ...
export class AppComponent {
    listData = [
        { id: 1, country: "Afghanistan", capital: "Kabul" },
        { id: 2, country: "Albania", capital: "Tirana" },
        // ...
    ];
}
@NgModule({
     imports: [
         // ...
         DxListModule
     ],
     // ...
 })
Vue
App.vue
<template>
    <DxList
        :data-source="listData"
        :search-enabled="true"
        :search-expr="['country', 'capital']"
        item-template="list-item">
        <template #list-item="{ data }">
            <div>{{ data.capital }} ({{ data.country }})</div>
        </template>
    </DxList>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';
import DxList from 'devextreme-vue/list';

const listData = [
    { id: 1, country: "Afghanistan", capital: "Kabul" },
    { id: 2, country: "Albania", capital: "Tirana" },
    // ...
];

export default {
    components: {
        DxList
    },
    data() {
        return {
            listData
        }
    }
}
</script>
React
App.js
import React from 'react';
import 'devextreme/dist/css/dx.light.css';
import List from 'devextreme-react/list';

const listData = [
    { id: 1, country: "Afghanistan", capital: "Kabul" },
    { id: 2, country: "Albania", capital: "Tirana" },
    // ...
];

const ListItem = (data) => {
    return (
        <div>{ data.capital } ({ data.country })</div>
    );
};

export default function App() {
    return (
        <List
            dataSource={listData}
            itemRender={ListItem}
            searchEnabled={true}
            searchExpr={['country', 'capital']}
        />
    );
}

View Demo

When a user types a string in the input field, the List suggests all items that contain this string. Assign 'startswith' to the searchMode property if you want the List to suggest only those items that start with the input string.

jQuery
JavaScript
$(function() {
    $("#listContainer").dxList({
        // ...
        searchMode: 'startswith'
    });
});
Angular
HTML
<dx-list ...
    searchMode="startswith">
</dx-list>
Vue
App.vue
<template>
    <DxList ...
        search-mode="startswith">
    </DxList>
</template>

<script>
// ...
</script>
React
App.js
// ...
export default function App() {
    return (
        <List ...
            searchMode="startswith"
        />
    );
}

You can customize the search panel by specifying the searchEditorOptions property. The following code changes the panel's default width and placeholder:

jQuery
JavaScript
$(function() {
    $("#listContainer").dxList({
        // ...
        searchEditorOptions: {
            placeholder: "Type search value here...",
            width: 300
        }
    });
});
Angular
HTML
<dx-list ... >
    <dxo-search-editor-options
        placeholder="Type search value here..."
        [width]="300">
    </dxo-search-editor-options>
</dx-list>
Vue
App.vue
<template>
    <DxList ... >
        <DxSearchEditorOptions
            placeholder="Type search value here..."
            :width="300"
        />
    </DxList>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';
import DxList, {
    DxSearchEditorOptions
} from 'devextreme-vue/list';

export default {
    components: {
        DxList,
        DxSearchEditorOptions
    },
    // ...
}
</script>
React
App.js
import React from 'react';
import 'devextreme/dist/css/dx.light.css';
import List, {
    SearchEditorOptions
} from 'devextreme-react/list';

export default function App() {
    return (
        <List ... >
            <SearchEditorOptions
                placeholder="Type search value here..."
                width={300}
            />
        </List>
    );
}
See Also