Your search did not match any results.
Range Selector

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
$(function(){ var showEmployees = function(employees) { var employee, tableHtml; if ($('#selectedEmployees').length === 0) { $('#range-selector-demo').append("<center><h2>Selected Employees</h2> <div id='selectedEmployees' /></center>"); } $('#selectedEmployees').empty(); tableHtml = '<table><tr>'; $.each(['First Name', 'Last Name', 'Birth Year', 'City', 'Title'], function () { tableHtml += '<td><b>' + this + '</b></td>'; }); tableHtml += '</tr>'; $.each(employees, function () { tableHtml += '<tr><td>' + this.FirstName + '</td><td>' + this.LastName + '</td><td>' + this.BirthYear + '</td><td>' + this.City + '</td><td>' + this.Title + '</td></tr>'; }); tableHtml += '</table>'; $('#selectedEmployees').html(tableHtml); }; $("#range-selector-demo").dxRangeSelector({ margin: { top: 20 }, size: { height: 140 }, dataSource: employees, dataSourceField: "BirthYear", scale: { tickInterval: 1, minorTickInterval: 1 }, behavior: { callValueChanged: "onMoving" }, title: "Filter Employee List by Birth Year", onValueChanged: function (e) { var selectedEmployees = $.grep(employees, function(employee) { return employee.BirthYear >= e.value[0] && employee.BirthYear <= e.value[1]; }); showEmployees(selectedEmployees); } }); showEmployees(employees); });
<!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> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.spa.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/17.1.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> </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" } ];