DevExtreme v23.2 is now available.

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

Your search did not match any results.

Use Range Selection for Filtering

Documentation

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

Backend API
$(() => { $('#data-grid').dxDataGrid({ dataSource: employees, columns: ['FirstName', 'LastName', 'BirthYear', 'City', 'Title'], showBorders: true, columnAutoWidth: true, }); $('#range-selector').dxRangeSelector({ margin: { top: 20, }, dataSource: employees, dataSourceField: 'BirthYear', scale: { tickInterval: 1, minorTickInterval: 1, label: { format: { type: 'decimal', }, }, }, behavior: { valueChangeMode: 'onHandleMove', }, title: 'Filter Employee List by Birth Year', onValueChanged(e) { const selectedEmployees = $.grep( employees, (employee) => employee.BirthYear >= e.value[0] && employee.BirthYear <= e.value[1], ); $('#data-grid').dxDataGrid({ dataSource: selectedEmployees, }); }, }); });
<!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.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" /> <script src="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"></div> <h2 class="grid-header">Selected Employees</h2> <div id="data-grid"></div> </div> </body> </html>
#range-selector { height: 140px; } h2.grid-header { font-size: 20px; margin: 38px 0 10px; text-align: center; }
const 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', }, ];