Help us shape the 2021 DevExtreme Roadmap. Take our 5 minute survey.
Your search did not match any results.
Data Grid

Filtering API


The DataGrid includes the following API you can use to filter data:

In this demo, you can use the SelectBox widget to filter the grid's dataSource. The "All" item calls the clearFilter() method and the other items call the filter(filterExpr) method.

Copy to CodeSandBox
<template> <div> <div class="left-side"> <div class="logo"> <img src="../../../../images/logo-devav.png"> <img src="../../../../images/logo-tasks.png"> </div> </div> <div class="right-side"> <DxSelectBox :items="statuses" :value="statuses[0]" @value-changed="onValueChanged" /> </div> <DxDataGrid id="gridContainer" :ref="dataGridRefName" :data-source="dataSource" :column-auto-width="true" :show-borders="true" > <DxColumn :width="80" data-field="Task_ID" /> <DxColumn data-field="Task_Start_Date" data-type="date" caption="Start Date" /> <DxColumn :allow-sorting="false" data-field="ResponsibleEmployee.Employee_Full_Name" css-class="employee" caption="Assigned To" /> <DxColumn :width="350" data-field="Task_Subject" caption="Subject" /> <DxColumn data-field="Task_Status" caption="Status" /> </DxDataGrid> </div> </template> <script> import { DxColumn, DxDataGrid } from 'devextreme-vue/data-grid'; import DxSelectBox from 'devextreme-vue/select-box'; import 'devextreme/data/odata/store'; export default { components: { DxSelectBox, DxColumn, DxDataGrid }, data() { return { dataSource: { store: { type: 'odata', url: '' }, expand: 'ResponsibleEmployee', select: [ 'Task_ID', 'Task_Subject', 'Task_Start_Date', 'Task_Status', 'ResponsibleEmployee/Employee_Full_Name' ] }, statuses: ['All', 'Not Started', 'In Progress', 'Need Assistance', 'Deferred', 'Completed'], dataGridRefName: 'dataGrid', }; }, methods: { onValueChanged({ value }) { const dataGrid = this.$refs[this.dataGridRefName].instance; if (value === 'All') { dataGrid.clearFilter(); } else { dataGrid.filter(['Task_Status', '=', value]); } } } }; </script> <style scoped> .right-side { position: absolute; right: 1px; top: 6px; } .logo { line-height: 48px; } .logo img { vertical-align: middle; margin: 0 5px; } .logo img:first-child { margin-right: 9px; } .dx-row.dx-data-row .employee { color: #bf4e6a; font-weight: bold; } #gridContainer { margin: 20px 0; height: 400px; } </style>
import { createApp } from 'vue'; import App from './App.vue'; createApp(App).mount('#app');
<!DOCTYPE html> <html> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <link rel="stylesheet" type="text/css" href="" /> <link rel="stylesheet" type="text/css" href="" /> <script src=""></script> <script src=""></script> <script type="text/javascript" src="config.js"></script> <script type="text/javascript"> System.import('./index.js'); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"> </div> </div> </body> </html>
System.config({ transpiler: 'plugin-babel', meta: { '*.vue': { loader: 'vue-loader' }, }, paths: { 'npm:': '' }, map: { 'vue': 'npm:vue@3.0.0/dist/vue.esm-browser.js', 'vue-loader': 'npm:dx-systemjs-vue-browser@1.0.15/index.js', 'mitt': 'npm:mitt/dist/mitt.umd.js', 'rrule': 'npm:rrule@2.6.6/dist/es5/rrule.js', 'luxon': 'npm:luxon@1.25.0/build/global/luxon.min.js', 'es6-object-assign': 'npm:es6-object-assign@1.1.0', 'devextreme': 'npm:devextreme@20.2.4', 'devextreme-vue': 'npm:devextreme-vue@20.2.4', 'jszip': 'npm:jszip@3.5.0/dist/jszip.min.js', 'devextreme-quill': 'npm:devextreme-quill@0.9.7/dist/dx-quill.min.js', 'devexpress-diagram': 'npm:devexpress-diagram@2.0.5/dist/dx-diagram.js', 'devexpress-gantt': 'npm:devexpress-gantt@2.0.8/dist/dx-gantt.js', 'preact': 'npm:preact@10.5.7/dist/preact.js', 'preact/hooks': 'npm:preact@10.5.7/hooks/dist/hooks.js', 'plugin-babel': 'npm:systemjs-plugin-babel@0.0.25/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel@0.0.25/systemjs-babel-browser.js' }, packages: { 'devextreme-vue': { main: 'index.js' }, 'devextreme': { defaultExtension: 'js' }, 'devextreme/events/utils': { main: 'index' }, 'devextreme/events': { main: 'index' }, 'es6-object-assign': { main: './index.js', defaultExtension: 'js' } }, babelOptions: { sourceMaps: false, stage0: true } });