Your search did not match any results.
Filter Builder

With Data Grid

Documentation

This demo shows how to use a standalone FilterBuilder to filter data in the DataGrid component. The DataGrid also has an integrated filter builder that can be invoked using the filter panel (see the Filter Panel demo).

Backend API
Copy to CodePen
Apply
Reset
const DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', ($scope) => { $scope.filterBuilderValue = filter; $scope.dataGridFilter = filter; $scope.filterBuilderOptions = { fields, bindingOptions: { value: 'filterBuilderValue', }, }; $scope.buttonOptions = { text: 'Apply Filter', type: 'default', onClick() { $scope.dataGridFilter = $scope.filterBuilderValue; }, }; $scope.dataGridOptions = { columns: fields, showBorders: true, dataSource: { store: { type: 'odata', fieldTypes: { Product_Cost: 'Decimal', Product_Sale_Price: 'Decimal', Product_Retail_Price: 'Decimal', }, url: 'https://js.devexpress.com/Demos/DevAV/odata/Products', }, select: [ 'Product_ID', 'Product_Name', 'Product_Cost', 'Product_Sale_Price', 'Product_Retail_Price', 'Product_Current_Inventory', ], }, bindingOptions: { filterValue: 'dataGridFilter', }, height: 300, }; });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <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" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/22.1.3/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/22.1.3/css/dx.light.css" /> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script> <script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C/script%3E'))</script> <script src="https://cdn3.devexpress.com/jslib/22.1.3/js/dx.all.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="data.js"></script> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container" ng-app="DemoApp" ng-controller="DemoController"> <div class="filter-container"> <div dx-filter-builder="filterBuilderOptions"></div> <div dx-button="buttonOptions"></div> <div class="dx-clearfix"></div> </div> <div dx-data-grid="dataGridOptions"></div> </div> </body> </html>
.filter-container { background-color: rgba(191, 191, 191, 0.15); padding: 5px; width: 500px; margin-bottom: 25px; } .dx-filterbuilder { padding: 10px; } .dx-button { margin: 10px; float: right; } .dx-filterbuilder .dx-numberbox { width: 80px; }
const filter = [ ['Product_Current_Inventory', '<>', 0], 'or', [ ['Product_Name', 'contains', 'HD'], 'and', ['Product_Cost', '<', 200], ], ]; const fields = [ { caption: 'ID', width: 50, dataField: 'Product_ID', dataType: 'number', }, { dataField: 'Product_Name', dataType: 'string', }, { caption: 'Cost', dataField: 'Product_Cost', dataType: 'number', format: 'currency', }, { dataField: 'Product_Sale_Price', caption: 'Sale Price', dataType: 'number', format: 'currency', }, { dataField: 'Product_Retail_Price', caption: 'Retail Price', dataType: 'number', format: 'currency', }, { dataField: 'Product_Current_Inventory', dataType: 'number', caption: 'Inventory', }, ];