Your search did not match any results.
FilterBuilder

With Data Grid

Documentation

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

Copy to CodePen
Apply
Reset
window.onload = function() { var filterBuilderValue = ko.observable(filter), dataGridFilter = ko.observable(filter); var viewModel = { filterBuilderOptions: { fields: fields, value: filterBuilderValue }, buttonOptions: { text: "Apply Filter", type: "default", onClick: function() { dataGridFilter(filterBuilderValue()); }, }, 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" ] }, filterValue: dataGridFilter, height: 300 } }; ko.applyBindings(viewModel, document.getElementById("demo")); };
<!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.1.0/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/18.2.3/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/18.2.3/css/dx.light.css" /> <link rel="dx-theme" data-theme="android5.light" href="https://cdn3.devexpress.com/jslib/18.2.3/css/dx.android5.light.css" /> <link rel="dx-theme" data-theme="ios7.default" href="https://cdn3.devexpress.com/jslib/18.2.3/css/dx.ios7.default.css" /> <link rel="dx-theme" data-theme="win10.black" href="https://cdn3.devexpress.com/jslib/18.2.3/css/dx.win10.black.css" /> <link rel="dx-theme" data-theme="win10.white" href="https://cdn3.devexpress.com/jslib/18.2.3/css/dx.win10.white.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://cdn3.devexpress.com/jslib/18.2.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"> <div class="filter-container"> <div data-bind="dxFilterBuilder: filterBuilderOptions"></div> <div data-bind="dxButton: buttonOptions"></div> <div class="dx-clearfix"></div> </div> <div data-bind="dxDataGrid: 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; }
var filter = [ ["Product_Current_Inventory", "<>", 0], "or", [ ["Product_Name", "contains", "HD"], "and", ["Product_Cost", "<", 200] ] ], 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" } ];