DevExtreme v23.2 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

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
$(() => { $('#filterBuilder').dxFilterBuilder({ fields, value: filter, }); $('#apply').dxButton({ text: 'Apply Filter', type: 'default', onClick() { const filter = $('#filterBuilder').dxFilterBuilder('instance').option('value'); $('#dataGrid').dxDataGrid('instance').option('filterValue', filter); }, }); $('#dataGrid').dxDataGrid({ columns: fields, showBorders: true, dataSource: { store: { type: 'odata', version: 2, 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', ], }, filterValue: filter, height: 300, }); });
<!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" /> <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/23.2.5/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="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"> <div class="filter-container"> <div id="filterBuilder"></div> <div id="apply"></div> <div class="dx-clearfix"></div> </div> <div id="dataGrid"></div> </div> </body> </html>
.filter-container { background-color: transparent; box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.14), 0 0 2px 0 rgba(0, 0, 0, 0.12); border-radius: 6px; padding: 5px; width: 500px; margin: 24px; } .dx-filterbuilder { background-color: transparent; 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', }, ];