Your search did not match any results.
Data Grid

Filtering API

Documentation

The DataGrid widget ships with an integrated filtering API, allowing you apply filters in code. In this example, the grid’s filter function is called to filter data based on selections made within the drop-down menu above the DataGrid.

Copy to CodeSandBox
Apply
Reset
<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"> <dx-select-box :items="statuses" :value="statuses[0]" @value-changed="onValueChanged" /> </div> <dx-data-grid id="gridContainer" :ref="dataGridRefName" :data-source="dataSource" :column-auto-width="true" :show-borders="true" > <dx-column :width="80" data-field="Task_ID" /> <dx-column data-field="Task_Start_Date" data-type="date" caption="Start Date" /> <dx-column :allow-sorting="false" data-field="ResponsibleEmployee.Employee_Full_Name" css-class="employee" caption="Assigned To" /> <dx-column :width="350" data-field="Task_Subject" caption="Subject" /> <dx-column data-field="Task_Status" caption="Status" /> </dx-data-grid> </div> </template> <script> import { DxColumn, DxDataGrid } from 'devextreme-vue/data-grid'; import { DxSelectBox } from 'devextreme-vue'; import 'devextreme/data/odata/store'; export default { components: { DxSelectBox, DxColumn, DxDataGrid }, data() { return { dataSource: { store: { type: 'odata', url: 'https://js.devexpress.com/Demos/DevAV/odata/Tasks' }, 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; } .dx-row.dx-data-row .employee { color: #bf4e6a; font-weight: bold; } #gridContainer { margin: 20px 0; height: 400px; } </style>
import Vue from 'vue'; import App from './App.vue'; new Vue({ el: '#app', components: { App }, template: '<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="https://cdn3.devexpress.com/jslib/19.1.3/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/19.1.3/css/dx.light.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></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"> <span v-if="false">Loading...</span> </div> </div> </body> </html>
System.config({ transpiler: 'plugin-babel', paths: { 'npm:': 'https://unpkg.com/' }, map: { vue: 'npm:vue@2.5.16/dist/vue.esm.browser.js', 'vue-loader': 'npm:systemjs-vue-browser@latest/index.js', 'devextreme': 'npm:devextreme@19.1', 'devextreme-vue': 'npm:devextreme-vue@19.1', jszip: 'npm:jszip@3.1.3/dist/jszip.min.js', 'quill': 'npm:quill@1.3.6/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram', 'plugin-babel': 'npm:systemjs-plugin-babel@0/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel@0/systemjs-babel-browser.js' }, meta: { '*.vue': { loader: 'vue-loader' } }, packages: { 'devextreme-vue': { main: 'index.js' }, 'devextreme': { defaultExtension: 'js' } }, babelOptions: { sourceMaps: false, stage0: true } });