Your search did not match any results.
FilterBuilder

With Data Grid

Documentation

This demo shows how to filter data in the DataGrid using the FilterBuilder widget.

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" ], filter: 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="js/jquery-3.1.0.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.2.3/css/dx.spa.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.2.3/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/17.2.3/css/dx.light.css" /> <link rel="dx-theme" data-theme="android5.light" href="https://cdn3.devexpress.com/jslib/17.2.3/css/dx.android5.light.css" /> <link rel="dx-theme" data-theme="ios7.default" href="https://cdn3.devexpress.com/jslib/17.2.3/css/dx.ios7.default.css" /> <link rel="dx-theme" data-theme="win10.black" href="https://cdn3.devexpress.com/jslib/17.2.3/css/dx.win10.black.css" /> <link rel="dx-theme" data-theme="win10.white" href="https://cdn3.devexpress.com/jslib/17.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/17.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; }
var filter = [ ["Product_Current_Inventory", "<>", 0], "Or", [ ["Product_Name", "contains", "HD"], ["Product_Cost", "<", 200] ] ], fields = [ { caption: "ID", width: 50, dataField: "Product_ID", dataType: "number" }, { dataField: "Product_Name" }, { 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" } ];