Your search did not match any results.
RangeSelector

Use Range Selection for Filtering

Documentation

The RangeSelector widget allows you to handle changes of the currently selected range. For this purpose, the callback function is specified in the onValueChanged option. This demo illustrates how to use the newly selected range for filtering data.

Copy to CodePen
Apply
Reset
window.onload = function() { var selectedEmployees = ko.observable(employees); var viewModel = { selectedEmployees: selectedEmployees, rangeSelectorOptions: { margin: { top: 20 }, size: { height: 140 }, dataSource: employees, scale: { tickInterval: 1, minorTickInterval: 1, label: { format: { type: "decimal" } } }, dataSourceField: "BirthYear", behavior: { callValueChanged: "onMoving" }, title: "Filter Employee List by Birth Year", onValueChanged: function (e) { var employeesValue = $.grep(employees, function(employee) { return employee.BirthYear >= e.value[0] && employee.BirthYear <= e.value[1]; }); selectedEmployees(employeesValue); } } }; ko.applyBindings(viewModel, $("#range-selector-demo").get(0)); };
<!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" /> <script src="https://cdn3.devexpress.com/jslib/17.2.3/js/dx.all.js"></script> <script src="data.js"></script> <link rel="stylesheet" type ="text/css" href ="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="range-selector-demo"> <div data-bind="dxRangeSelector: rangeSelectorOptions"></div> <h2>Selected Employees</h2> <table> <tr> <td> <b>First Name</b> </td> <td> <b>Last Name</b> </td> <td> <b>Birth Year</b> </td> <td> <b>City</b> </td> <td> <b>Title</b> </td> </tr> <tbody data-bind="foreach: selectedEmployees"> <tr> <td data-bind="text: $data.FirstName"></td> <td data-bind="text: $data.LastName"></td> <td data-bind="text: $data.BirthYear"></td> <td data-bind="text: $data.City"></td> <td data-bind="text: $data.Title"></td> </tr> </tbody> </table> </div> </div> </body> </html>
#range-selector-demo { height: 440px; width: 100%; } h2 { margin-top: 38px; text-align: center; } table { width: 100%; } td { width: 20%; }
var employees = [ { LastName: "Davolio", FirstName: "Nancy", BirthYear: 1948, City: "Seattle", Title: "Sales Representative" }, { LastName: "Fuller", FirstName: "Andrew", BirthYear: 1952, City: "Tacoma", Title: "Vice President, Sales" }, { LastName: "Leverling", FirstName: "Janet", BirthYear: 1963, City: "Kirkland", Title: "Sales Representative" }, { LastName: "Peacock", FirstName: "Margaret", BirthYear: 1937, City: "Redmond", Title: "Sales Representative" }, { LastName: "Buchanan", FirstName: "Steven", BirthYear: 1955, City: "London", Title: "Sales Manager" }, { LastName: "Suyama", FirstName: "Michael", BirthYear: 1963, City: "London", Title: "Sales Representative" }, { LastName: "King", FirstName: "Robert", BirthYear: 1960, City: "London", Title: "Sales Representative" }, { LastName: "Callahan", FirstName: "Laura", BirthYear: 1958, City: "Seattle", Title: "Inside Sales Coordinator" }, { LastName: "Dodsworth", FirstName: "Anne", BirthYear: 1966, City: "London", Title: "Sales Representative" } ];