Overview
The JavaScript Query Builder is a rich and responsive UI for filtering large amounts of data by creating or editing conditions that can be combined with data visualization controls like DataGrid and Charts to view the filtered data. It outputs structured JSON filters that can be easily parsed to create SQL queries. It allows you to create conditions and group them using AND/OR logic.
Data Binding
JavaScript Query Builder can be bound to data from a variety of data sources in the form of a JavaScript object array collection. It auto populates the data source and maps the data to the appropriate fields.
Integration with Data Manager
Integrating the Data Manager control with JavaScript Query Builder simplifies communication with a data source and returns the desired result based on the provided filters.
Templates
Templates are used to create a custom user experience. JavaScript Query Builder provides template support to integrate with other input components such as Dropdown List, AutoComplete , Checkbox, Slider, and others.
Summary View
JavaScript Query Builder supports a summary view that outputs the filter query in SQL format.
Import and export
Import and export Query Builder data to and from structured JSON and SQL formats.
Touch-friendly and Responsive
JavaScript Query Builder provides a responsive mode that gives an adaptive, redesigned UI appearance for mobile devices and a great user experience on all phone, tablet, and desktop form factors.
JavaScript Query Builder Code Example
Easily get started with JavaScript Query Builder using a few simple lines of HTML and TS code, as demonstrated below. Also explore our JavaScript Query Builder Example that shows you how to render and configure the JavaScript Query Builder Component.
import { QueryBuilder, ColumnsModel, RuleModel } from '@syncfusion/ej2-querybuilder';
import { employeeData } from './data-source';
let columnData: ColumnsModel[] = [
{ field: 'EmployeeID', label: 'Employee ID', type: 'number' },
{ field: 'FirstName', label: 'First Name', type: 'string' },
{ field: 'TitleOfCourtesy', label: 'Title Of Courtesy', type: 'boolean', values: ['Mr.', 'Mrs.'] },
{ field: 'Title', label: 'Title', type: 'string' },
{ field: 'HireDate', label: 'Hire Date', type: 'date', format: 'dd/MM/yyyy' },
{ field: 'Country', label: 'Country', type: 'string' },
{ field: 'City', label: 'City', type: 'string' }
];
let importRules: RuleModel = {
'condition': 'and',
'rules': [{
'label': 'EmployeeID',
'field': 'EmployeeID',
'type': 'number',
'operator': 'equal',
'value': 1
},
{
'label': 'Title',
'field': 'Title',
'type': 'string',
'operator': 'equal',
'value': 'Sales Manager'
}]
};
let qryBldrObj: QueryBuilder = new QueryBuilder({
width: '70%',
dataSource: employeeData,
columns: columnData,
rule: importRules
});
qryBldrObj.appendTo('#querybuilder');
Other supported frameworks
The Query Builder component is also available in Blazor, React, Angular, and Vue frameworks. Check out the different Query Builder platforms from the links below,
Web accessibility
Fully supports WAI-ARIA accessibility to work with screen readers and assistive devices.
Follows WAI-ARIA best practices for implementing keyboard interaction.
Follows WCAG 2.0 standards in design of the UI element visuals such as foreground color, background color, line spacing, text, and images.
Supports right-to-left (RTL) text direction for users working in right-to-left languages like Hebrew, Arabic, or Persian.
Themes
The JavaScript Query Builder supports several built-in themes such as material, bootstrap, fabric (office 365), and high contrast. The users can customize any one of these built-in themes or create new themes to achieve their own desired look and feel either by simply overriding SASS variables or using our Theme Studio application with ease.