QueryBuilder — Smart UI JavaScript API
On this page + Quick start
Quick start · JavaScript
Complete starter source per framework. Run the scaffold/install command first, then replace the listed files with the full code below.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>QueryBuilder - JavaScript Quick Start</title>
<link rel="stylesheet" href="./node_modules/smart-webcomponents/source/styles/smart.default.css" />
</head>
<body>
<smart-query-builder id="demo-querybuilder"></smart-query-builder>
<script type="module">
import './node_modules/smart-webcomponents/source/modules/smart.querybuilder.js';
const el = document.getElementById('demo-querybuilder');
if (el) {
el.fields = [
{ label: 'First Name', dataField: 'firstName', dataType: 'string' },
{ label: 'Quantity', dataField: 'quantity', dataType: 'number' },
{ label: 'In Stock', dataField: 'inStock', dataType: 'boolean' }
];
el.value = [
['firstName', 'contains', 'an'],
'and',
['quantity', '>', 2]
];
el.addEventListener('change', (event) => console.log('change:', event.detail || event));
}
</script>
</body>
</html>
For AI tooling
Developer Quick Reference
Component: QueryBuilder Framework: JavaScript Selector: smart-query-builder
API counts: 30 properties, 1 methods, 7 events
Common properties: 0, 1, 2, 3, 4, 5
Common methods: getLinq()
Common events: change, dragEnd, dragging, dragStart, itemClick, propertySelected
Module hint: smart-webcomponents/source/modules/smart.querybuilder.js
QueryBuilder allows you to build dynamically queries for filtering.
Class
QueryBuilder
QueryBuilder allows you to build dynamically queries for filtering.
Selector
smart-query-builder
Properties
- label:string - label to be displayed in the operator box. Multiple operations with the same label can exist
- name:string - A unique name for the operation.
- editorTemplate:function - A callback function that creates a custom value editor. Takes three arguemnts:
- fieldType - the type of the field for the operation.
- value - the value of the condition.
- fieldData - the field object.
- valueTemplate:function - A callback function that displays the value after the edior has been closed. Takes two argument:
- editor - the custom editor element
- value - the condition value.
- handleValue:function - A callback function that handles the value returned by the editor when it is closed. The callback takes one arguemnt - the custom editor element. If the dataType is 'object' the expected result from the function should contain a 'label' and 'value' attributes. Where the label will be used for displaying purposes while 'value' will be used as the actual value.
- hideValue:boolean - A boolean condition that specifies whether the operation requires a value or not.
- validateValue:function - A callback that is executed when QueryBuilder validation is triggered. The callback takes one argument, the value of the condition. The function should return true or false to determine whether the conditon is valid or not.
- onEditorOpen:function - A callback that is called when the custom editor is rendered, visible inside the DOM and ready to be opened. The callback has one parameter - the custom editor element.
- expressionTemplate:string - A string representing a custom Linq expression template. If the value of the element is a string it will be considered as a Linq expression and it will be checked against all expressionTemplates to find a match.
- expressionReaderCallback:function - A callback that is used to specify which arguments from the expression are used for the fieldName and value. Used when converting a Linq expression to QueryBuilder value. Takes two arguments:
- expression - the LinQ expression defined in the expressionTemplate of the customOperator. Type string
- bindings - an array of expression parameters based on the expression template of the customOperator. Type string[]
- expressionBuilderCallback:function - A callback function that is used to specify which arguments from the Linq expression are used for the fieldName and value when building the Linq expression from the current value of the element. Takes three arguments:
- name - the name of the dataField. Type string.
- operation - the name of the operation. Type string
- value - the value of the operation. Type any( depends on the dataField).
- label:string - Sets or gets the label.
- dataField:string - Sets or gets the data field
- dataType:string - Sets or gets the data type.
- format:string - Sets or gets the filter format.
- filterOperations:string[] - Sets or gets the filter operations.
Events
Methods
Properties
allowDragAllows users to drag and reorder conditions within a single group or move conditions between different groups, facilitating flexible arrangement and organization of conditions through a user-friendly drag-and-drop interface.boolean
Allows users to drag and reorder conditions within a single group or move conditions between different groups, facilitating flexible arrangement and organization of conditions through a user-friendly drag-and-drop interface.
Default value
falseExamples
Markup and runtime examples for allowDrag:
HTML attribute:
<smart-query-builder allow-drag></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.allowDrag = false;Read the current value:
const el = document.querySelector('smart-query-builder');
const allowDrag = el.allowDrag;
animationSpecifies or retrieves the current animation mode. When this property is set to 'none', all animations are disabled. Otherwise, the selected mode determines how animations are displayed within the component."none" | "simple" | "advanced"
Specifies or retrieves the current animation mode. When this property is set to 'none', all animations are disabled. Otherwise, the selected mode determines how animations are displayed within the component.
Allowed Values
- "none" - animation is disabled
- "simple" - ripple animation is disabled
- "advanced" - all animations are enabled
Default value
"advanced"Examples
Markup and runtime examples for animation:
HTML:
<smart-query-builder animation="none"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.animation = "simple";Read the current value:
const el = document.querySelector('smart-query-builder');
const animation = el.animation;
applyModeControls the timing of when the element’s value is updated in response to changes, such as user input or interactions. This setting specifies whether the value updates immediately as the user types, when the input loses focus, or upon a specific event."change" | "immediately"
Controls the timing of when the element’s value is updated in response to changes, such as user input or interactions. This setting specifies whether the value updates immediately as the user types, when the input loses focus, or upon a specific event.
Allowed Values
- "change" - The value of the element is updated when a change event is fired form one of the editors.
- "immediately" - The value of the element is updated immediately after an editor's value is changed.
Default value
"change"Examples
Markup and runtime examples for applyMode:
HTML:
<smart-query-builder apply-mode="immediately"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.applyMode = "change";Read the current value:
const el = document.querySelector('smart-query-builder');
const applyMode = el.applyMode;
autoApplyValueWhen 'applyMode' is set to 'immediately', the default value is instantly assigned to the editor's value, and the QueryBuilder's value is updated in real-time without requiring any additional user action. This ensures that changes are automatically reflected as soon as the default value is set.boolean
When 'applyMode' is set to 'immediately', the default value is instantly assigned to the editor's value, and the QueryBuilder's value is updated in real-time without requiring any additional user action. This ensures that changes are automatically reflected as soon as the default value is set.
Default value
falseExamples
Markup and runtime examples for autoApplyValue:
HTML attribute:
<smart-query-builder auto-apply-value></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.autoApplyValue = false;Read the current value:
const el = document.querySelector('smart-query-builder');
const autoApplyValue = el.autoApplyValue;
autoPromptControls whether the QueryBuilder component will automatically display a prompt asking the user to enter a value when a new condition is added. If 'applyMode' is set to 'immediately', and the operation field of a newly created condition is empty, QueryBuilder will automatically populate the operation field when the user selects or changes the condition operator. Additionally, whenever the operation or operator of an existing condition is changed, the input field will prompt the user to enter a new value relevant to the updated condition. This ensures that condition values are collected promptly and accurately as users modify or add filtering criteria.boolean
Controls whether the QueryBuilder component will automatically display a prompt asking the user to enter a value when a new condition is added. If 'applyMode' is set to 'immediately', and the operation field of a newly created condition is empty, QueryBuilder will automatically populate the operation field when the user selects or changes the condition operator. Additionally, whenever the operation or operator of an existing condition is changed, the input field will prompt the user to enter a new value relevant to the updated condition. This ensures that condition values are collected promptly and accurately as users modify or add filtering criteria.
Default value
falseExamples
Markup and runtime examples for autoPrompt:
HTML attribute:
<smart-query-builder auto-prompt></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.autoPrompt = false;Read the current value:
const el = document.querySelector('smart-query-builder');
const autoPrompt = el.autoPrompt;
customOperationsEnhances the query builder’s condition structure by allowing additional custom operations. Each custom operation can be defined with the following fields:
Click for more details. Property object's options:
{label: string, name: string, editorTemplate: function, valueTemplate: function, handleValue: function, hideValue: boolean, expressionTemplate: string, expressionReaderCallback: function, expressionBuilderCallback: function}[]
Enhances the query builder’s condition structure by allowing additional custom operations. Each custom operation can be defined with the following fields:
Properties
Examples
Markup and runtime examples for customOperations:
HTML:
<smart-query-builder custom-operations="[{ label: "Matches /^\d{7}$/g", name: "/^\d{7}$/g", hideValue: true }, { label: "Similar to", name: "similar" }]"></smart-query-builder>Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.customOperations = [{ label: 'Is valid', name: 'isvalid' }];Read the current value:
const el = document.querySelector('smart-query-builder');
const customOperations = el.customOperations;
editorTemplateA callback function that creates a custom value editor. Takes three arguemnts: fieldType - the type of the field for the operation.value - the value of the condition.fieldData - the field object.function
A callback function that creates a custom value editor. Takes three arguemnts:
fieldType - the type of the field for the operation.
value - the value of the condition.
fieldData - the field object.
Read the nested value:
const el = document.querySelector('smart-query-builder');
const editorTemplate = el.customOperations[0].editorTemplate;
expressionBuilderCallbackA callback function that is used to specify which arguments from the Linq expression are used for the fieldName and value when building the Linq expression from the current value of the element. Takes three arguments: name - the name of the dataField. Type string.operation - the name of the operation. Type stringvalue - the value of the operation. Type any( depends on the dataField).function
A callback function that is used to specify which arguments from the Linq expression are used for the fieldName and value when building the Linq expression from the current value of the element. Takes three arguments:
name - the name of the dataField. Type string.
operation - the name of the operation. Type string
value - the value of the operation. Type any( depends on the dataField).
Back to root property: customOperations
Try a demo showcasing the expressionBuilderCallback property.Read the nested value:
const el = document.querySelector('smart-query-builder');
const expressionBuilderCallback = el.customOperations[0].expressionBuilderCallback;
expressionReaderCallbackA callback that is used to specify which arguments from the expression are used for the fieldName and value. Used when converting a Linq expression to QueryBuilder value. Takes two arguments: expression - the LinQ expression defined in the expressionTemplate of the customOperator. Type stringbindings - an array of expression parameters based on the expression template of the customOperator. Type string[]function
A callback that is used to specify which arguments from the expression are used for the fieldName and value. Used when converting a Linq expression to QueryBuilder value. Takes two arguments:
expression - the LinQ expression defined in the expressionTemplate of the customOperator. Type string
bindings - an array of expression parameters based on the expression template of the customOperator. Type string[]
Back to root property: customOperations
Try a demo showcasing the expressionReaderCallback property.Read the nested value:
const el = document.querySelector('smart-query-builder');
const expressionReaderCallback = el.customOperations[0].expressionReaderCallback;
expressionTemplateA string representing a custom Linq expression template. If the value of the element is a string it will be considered as a Linq expression and it will be checked against all expressionTemplates to find a match.string
A string representing a custom Linq expression template. If the value of the element is a string it will be considered as a Linq expression and it will be checked against all expressionTemplates to find a match.
Default value
"null"Read the nested value:
const el = document.querySelector('smart-query-builder');
const expressionTemplate = el.customOperations[0].expressionTemplate;
handleValueA callback function that handles the value returned by the editor when it is closed. The callback takes one arguemnt - the custom editor element. If the dataType is 'object' the expected result from the function should contain a 'label' and 'value' attributes. Where the label will be used for displaying purposes while 'value' will be used as the actual value.function
A callback function that handles the value returned by the editor when it is closed. The callback takes one arguemnt - the custom editor element. If the dataType is 'object' the expected result from the function should contain a 'label' and 'value' attributes. Where the label will be used for displaying purposes while 'value' will be used as the actual value.
Read the nested value:
const el = document.querySelector('smart-query-builder');
const handleValue = el.customOperations[0].handleValue;
hideValueA boolean condition that specifies whether the operation requires a value or not.boolean
A boolean condition that specifies whether the operation requires a value or not.
Default value
falseRead the nested value:
const el = document.querySelector('smart-query-builder');
const hideValue = el.customOperations[0].hideValue;
labellabel to be displayed in the operator box. Multiple operations with the same label can existstring
label to be displayed in the operator box. Multiple operations with the same label can exist
Default value
""Read the nested value:
const el = document.querySelector('smart-query-builder');
const label = el.customOperations[0].label;
nameA unique name for the operation.string
A unique name for the operation.
Default value
""Read the nested value:
const el = document.querySelector('smart-query-builder');
const name = el.customOperations[0].name;
onEditorOpenA callback that is called when the custom editor is rendered, visible inside the DOM and ready to be opened. The callback has one parameter - the custom editor element.function
A callback that is called when the custom editor is rendered, visible inside the DOM and ready to be opened. The callback has one parameter - the custom editor element.
Read the nested value:
const el = document.querySelector('smart-query-builder');
const onEditorOpen = el.customOperations[0].onEditorOpen;
validateValueA callback that is executed when QueryBuilder validation is triggered. The callback takes one argument, the value of the condition. The function should return true or false to determine whether the conditon is valid or not.function
A callback that is executed when QueryBuilder validation is triggered. The callback takes one argument, the value of the condition. The function should return true or false to determine whether the conditon is valid or not.
Read the nested value:
const el = document.querySelector('smart-query-builder');
const validateValue = el.customOperations[0].validateValue;
valueTemplateA callback function that displays the value after the edior has been closed. Takes two argument: editor - the custom editor elementvalue - the condition value.function
A callback function that displays the value after the edior has been closed. Takes two argument:
editor - the custom editor element
value - the condition value.
Read the nested value:
const el = document.querySelector('smart-query-builder');
const valueTemplate = el.customOperations[0].valueTemplate;
disabledSpecifies whether the element is interactive and can receive user input. When enabled, the element functions normally. When disabled, the element becomes non-interactive and typically appears visually distinct (e.g., grayed out), preventing user actions such as clicks or text entry.boolean
Specifies whether the element is interactive and can receive user input. When enabled, the element functions normally. When disabled, the element becomes non-interactive and typically appears visually distinct (e.g., grayed out), preventing user actions such as clicks or text entry.
Default value
falseExamples
Markup and runtime examples for disabled:
HTML attribute:
<smart-query-builder disabled></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.disabled = false;Read the current value:
const el = document.querySelector('smart-query-builder');
const disabled = el.disabled;
dropDownWidthConfigures or retrieves the width (in pixels) of the dropdown menus used in both the property and operator editors, allowing for precise control over their display size in the user interface.string
Configures or retrieves the width (in pixels) of the dropdown menus used in both the property and operator editors, allowing for precise control over their display size in the user interface.
Default value
"100%"Examples
Markup and runtime examples for dropDownWidth:
HTML:
<smart-query-builder drop-down-width="300"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.dropDownWidth = "80%";Read the current value:
const el = document.querySelector('smart-query-builder');
const dropDownWidth = el.dropDownWidth;
fields''An array defining the filterable fields and their corresponding configuration options to control their behavior and appearance. Each field in the array is represented as an object and can be customized using the following properties:- 'label': The human-readable name for the field. This label will be displayed in the filter field selection dropdown.- 'dataField': The key or property name in your data source that corresponds to this field.- 'dataType': Specifies the type of data contained in the field, such as ''string'', ''number'', ''date'', etc. This setting can affect which filter operations are available.- 'filterOperations': An array specifying which filter operations (such as ''contains'', ''equals'', ''greaterThan'', etc.) can be applied to this field. If this property is omitted, a default set of operations appropriate to the data type will be used.- 'lookup': An object for configuring the value selection input when filtering this field. The 'lookup' object supports the following options: - 'autoCompleteDelay': The delay, in milliseconds, between when the user types in the value selection input and when the dropdown with available options appears. - 'dataSource': An array containing the set of predefined options that the user can choose from in the dropdown. - 'minLength': The minimum number of characters the user must enter in the input before the options dropdown is shown. - 'readonly': Set to 'true' to make the value selection input act as a standard dropdown (the user can only select from the list); set to 'false' for a combo box (the user can type custom values in addition to choosing from the list).This structure provides developers with fine-grained control over how each filter field appears and operates, including the available filter types and the way users select or enter filter values.
Click for more details. Property object's options:
{label: string, dataField: string, dataType: string, dataType: string, format: any, filterOperations: string[]}[]
''
An array defining the filterable fields and their corresponding configuration options to control their behavior and appearance. Each field in the array is represented as an object and can be customized using the following properties:
- 'label':
The human-readable name for the field. This label will be displayed in the filter field selection dropdown.
- 'dataField':
The key or property name in your data source that corresponds to this field.
- 'dataType':
Specifies the type of data contained in the field, such as ''string'', ''number'', ''date'', etc. This setting can affect which filter operations are available.
- 'filterOperations':
An array specifying which filter operations (such as ''contains'', ''equals'', ''greaterThan'', etc.) can be applied to this field. If this property is omitted, a default set of operations appropriate to the data type will be used.
- 'lookup':
An object for configuring the value selection input when filtering this field. The 'lookup' object supports the following options:
- 'autoCompleteDelay':
The delay, in milliseconds, between when the user types in the value selection input and when the dropdown with available options appears.
- 'dataSource':
An array containing the set of predefined options that the user can choose from in the dropdown.
- 'minLength':
The minimum number of characters the user must enter in the input before the options dropdown is shown.
- 'readonly':
Set to 'true' to make the value selection input act as a standard dropdown (the user can only select from the list); set to 'false' for a combo box (the user can type custom values in addition to choosing from the list).
This structure provides developers with fine-grained control over how each filter field appears and operates, including the available filter types and the way users select or enter filter values.
Properties
Examples
Markup and runtime examples for fields:
HTML:
<smart-query-builder fields="[{ "label": "id", "dataField": "id", "dataType": "number", "format": null, "filterOperations": ["=", "anyof"] }, { "label": "Product", "dataField": "productName", "dataType": "string", "format": null }]"></smart-query-builder>Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.fields = [{ "label": "id", "dataField": "id", "dataType": "number", "format": null, "filterOperations": ["=", "anyof"] }, { "label": "Product", "dataField": "productName", "dataType": "string", "format": null }];Read the current value:
const el = document.querySelector('smart-query-builder');
const fields = el.fields;
dataFieldSets or gets the data fieldstring
Sets or gets the data field
Default value
""Read the nested value:
const el = document.querySelector('smart-query-builder');
const dataField = el.fields[0].dataField;
dataTypeSets or gets the data type.string
Sets or gets the data type.
Default value
"string"Read the nested value:
const el = document.querySelector('smart-query-builder');
const dataType = el.fields[0].dataType;
filterOperationsSets or gets the filter operations.string[]
Sets or gets the filter operations.
Default value
[]Read the nested value:
const el = document.querySelector('smart-query-builder');
const filterOperations = el.fields[0].filterOperations;
formatSets or gets the filter format.string
Sets or gets the filter format.
Default value
""Read the nested value:
const el = document.querySelector('smart-query-builder');
const format = el.fields[0].format;
labelSets or gets the label.string
Sets or gets the label.
Default value
""Read the nested value:
const el = document.querySelector('smart-query-builder');
const label = el.fields[0].label;
fieldsModeControls whether users are allowed to create and add new fields by typing directly into the field (property) input box, enabling dynamic extension of available fields beyond the predefined options."dynamic" | "static"
Controls whether users are allowed to create and add new fields by typing directly into the field (property) input box, enabling dynamic extension of available fields beyond the predefined options.
Allowed Values
- "dynamic" - Allows to dynamically add new fields by typing inside the field input that is located inside a condition.
- "static" - Fields are only added statically via the fields property.
Default value
"dynamic"Examples
Markup and runtime examples for fieldsMode:
HTML:
<smart-query-builder fields-mode="static"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.fieldsMode = "dynamic";Read the current value:
const el = document.querySelector('smart-query-builder');
const fieldsMode = el.fieldsMode;
formatStringDateSpecifies or retrieves the format string used by the editor for fields of type 'date'. This determines how date values are displayed and parsed within the editor. Adjusting this string allows customization of the date format according to localization or application requirements.string
Specifies or retrieves the format string used by the editor for fields of type 'date'. This determines how date values are displayed and parsed within the editor. Adjusting this string allows customization of the date format according to localization or application requirements.
Default value
"dd-MMM-yy"Examples
Markup and runtime examples for formatStringDate:
HTML:
<smart-query-builder format-string-date="dddd-MMMM-yyyy"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.formatStringDate = "M/d/yyyy";Read the current value:
const el = document.querySelector('smart-query-builder');
const formatStringDate = el.formatStringDate;
formatStringDateTimeGets or sets the format string used by the editor for fields of type 'dateTime'. This format string determines how date and time values are displayed and parsed within the editor.string
Gets or sets the format string used by the editor for fields of type 'dateTime'. This format string determines how date and time values are displayed and parsed within the editor.
Default value
"dd-MMM-yy HH:mm:ss"Examples
Markup and runtime examples for formatStringDateTime:
HTML:
<smart-query-builder format-string-date-time="h:mm:ss tt"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.formatStringDateTime = "yyyy-MM-dd hh:mm:ss";Read the current value:
const el = document.querySelector('smart-query-builder');
const formatStringDateTime = el.formatStringDateTime;
getDynamicFieldA callback function that is invoked whenever a new field is dynamically added. This function allows you to configure or modify the settings of the newly added field before it is rendered. This callback is only applicable when fieldsMode is set to 'dynamic'.function | null
A callback function that is invoked whenever a new field is dynamically added. This function allows you to configure or modify the settings of the newly added field before it is rendered. This callback is only applicable when fieldsMode is set to 'dynamic'.
Examples
Markup and runtime examples for getDynamicField:
HTML:
<smart-query-builder get-dynamic-field="getDynamicFieldFunction"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.getDynamicField = "function (field) { return { dataField: field.toLowerCase(), dataType: 'number', filterOperations: ['<', '>'] }; }";Read the current value:
const el = document.querySelector('smart-query-builder');
const getDynamicField = el.getDynamicField;
iconsSpecifies the CSS classes assigned to each built-in operation, which determine the corresponding icons displayed for those operations. The icon styles are defined in the smart-query-builder stylesheet. This property takes effect only when showIcons is set to true, enabling visual representation of operations with their respective icons.any
Specifies the CSS classes assigned to each built-in operation, which determine the corresponding icons displayed for those operations. The icon styles are defined in the smart-query-builder stylesheet. This property takes effect only when showIcons is set to true, enabling visual representation of operations with their respective icons.
Default value
{ '=': 'equals', '<>': 'notequals', '>': 'greaterthan', '>=': 'greaterthanorequal', '<': 'lessthan', '<=': 'lessthanorequal', 'startswith': 'startswith', 'endswith': 'endswith', 'contains': 'contains', 'notcontains': 'notcontains', 'isblank': 'isblank', 'isnotblank': 'isnotblank' }Examples
Markup and runtime examples for icons:
HTML:
<smart-query-builder icons="{ "=": "equals", "<>": "notequals", ">": "greaterthan", ">=": "greaterthanorequal", "<": "lessthan", "<=": "lessthanorequal", "startswith": "startswith", "endswith": "endswith", "contains": "contains", "notcontains": "notcontains", "isblank": "blank", "isnotblank": "notblank" }"></smart-query-builder>Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.icons = { '=': 'equals', '<>': 'notequals', '>': 'greaterthan', '>=': 'greaterthanorequal', '<': 'lessthan', '<=': 'lessthanorequal', 'startswith': 'startswith', 'endswith': 'endswith', 'contains': 'contains', 'notcontains': 'notcontains', 'isblank': 'blank', 'isnotblank': 'notblank' };Read the current value:
const el = document.querySelector('smart-query-builder');
const icons = el.icons;
localeSpecifies or retrieves the current language code (e.g., "en", "fr", "es"). This property determines which set of messages from the messages object will be used for display or processing. Setting this property updates the active language, while getting it returns the currently selected language.string
Specifies or retrieves the current language code (e.g., "en", "fr", "es"). This property determines which set of messages from the messages object will be used for display or processing. Setting this property updates the active language, while getting it returns the currently selected language.
Default value
"en"Examples
Markup and runtime examples for locale:
HTML:
<smart-query-builder locale="de"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.locale = "fr";Read the current value:
const el = document.querySelector('smart-query-builder');
const locale = el.locale;
localizeFormatFunctionA callback function that allows you to define or modify the formatting of messages generated by the Localization Module before they are returned. Use this to customize message structure, apply additional processing, or support advanced localization needs.function | null
A callback function that allows you to define or modify the formatting of messages generated by the Localization Module before they are returned. Use this to customize message structure, apply additional processing, or support advanced localization needs.
Examples
Markup and runtime examples for localizeFormatFunction:
HTML:
<smart-query-builder localize-format-function="function(defaultMessage, message, messageArguments){return '...'}"></smart-query-builder>Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.localizeFormatFunction = "function(defaultMessage, message, messageArguments){return '...'}";Read the current value:
const el = document.querySelector('smart-query-builder');
const localizeFormatFunction = el.localizeFormatFunction;
messagesSpecifies the names of the fields to be included in the filtered element, allowing you to control which data properties are retained or displayed after filtering.object
Specifies the names of the fields to be included in the filtered element, allowing you to control which data properties are retained or displayed after filtering.
Default value
"en": {
"propertyUnknownType": "'{{name}}' property is with undefined 'type' member!",
"propertyInvalidValue": "Invalid '{{name}}' property value! Actual value: {{actualValue}}, Expected value: {{value}}!",
"propertyInvalidValueType": "Invalid '{{name}}' property value type! Actual type: {{actualType}}, Expected type: {{type}}!",
"elementNotInDOM": "Element does not exist in DOM! Please, add the element to the DOM, before invoking a method.",
"moduleUndefined": "Module is undefined.",
"missingReference": "{{elementType}}: Missing reference to {{files}}.",
"htmlTemplateNotSuported": "{{elementType}}: Browser doesn't support HTMLTemplate elements.",
"invalidTemplate": "{{elementType}}: '{{property}}' property accepts a string that must match the id of an HTMLTemplate element from the DOM.",
"add": "Add",
"addCondition": "Add Condition",
"addGroup": "Add Group",
"and": "And",
"notand": "Not And",
"or": "Or",
"notor": "Not Or",
"=": "Equals",
"<>": "Does not equal",
">": "Greater than",
">=": "Greater than or equal to",
"<": "Less than",
"<=": "Less than or equal to",
"startswith": "Starts with",
"endswith": "Ends with",
"contains": "Contains",
"notcontains": "Does not contain",
"isblank": "Is blank",
"isnotblank": "Is not blank",
"wrongParentGroupIndex": "{{elementType}}: Wrong parent group index in '{{method}}' method.",
"missingFields": "{{elementType}}: Fields are required for proper condition's adding. Set \"fields\" source and then conditions will be added as expected.",
"wrongElementNode": "{{elementType}}: Incorect node / node Id in '{{method}}' method.",
"invalidDataStructure": "{{elementType}}: Used invalid data structure in updateCondition/updateGroup method.",
"dateTabLabel": "DATE",
"timeTabLabel": "TIME",
"queryLabel": "Query"
}
Examples
Markup and runtime examples for messages:
HTML:
<smart-query-builder messages="{"de":{"propertyUnknownType":"Die Eigenschaft '{{name}}' hat ein nicht definiertes 'type'-Member!","propertyInvalidValue":"Ungultiger Eigenschaftswert '{{name}}'! Aktueller Wert: {{actualValue}}, Erwarteter Wert: {{value}}!","propertyInvalidValueType":"Ungultiger Eigenschaftswert '{{name}}'! Aktueller Wert: {{actualType}}, Erwarteter Wert: {{type}}!","elementNotInDOM":"Element existiert nicht in DOM! Bitte fugen Sie das Element zum DOM hinzu, bevor Sie eine Methode aufrufen.","moduleUndefined":"Modul ist nicht definiert.","missingReference":"{{elementType}}: Fehlender Verweis auf {{files}}.","htmlTemplateNotSuported":"{{elementType}}: Browser unterstutzt keine HTMLTemplate-Elemente.","invalidTemplate":"{{elementType}}: '{{property}}' Die Eigenschaft akzeptiert eine Zeichenfolge, die mit der ID eines HTMLTemplate-Elements aus dem DOM ubereinstimmen muss.","add":"Hinzufügen", "addCondition":"Bedingung hinzufugen","addGroup":"Gruppe hinzufugen","and":"Und","notand":"Nicht und","or":"Oder","notor":"Nicht oder","=":"Gleich","<>":"Ist nicht gleich",">":"Greusser als",">=":"Greusser als oder gleich wie","<":"Weniger als","<=":"Weniger als oder gleich","startswith":"Beginnt mit","endswith":"Endet mit","contains":"Enthalt","notcontains":"Beinhaltet nicht","isblank":"Ist leer","isnotblank":"Ist nicht leer","wrongParentGroupIndex":"{{elementType}}: Falscher ubergeordneter Gruppenindex in der Methode '{{method}}'.","missingFields":"{{elementType}}: Felder sind fur das Hinzufugen der richtigen Bedingung erforderlich. Legen Sie die Quelle fur \"Felder\" fest, und die Bedingungen werden wie erwartet hinzugefugt.","wrongElementNode":"{{elementType}}: Falsche Knoten- / Knoten-ID in der Methode '{{method}}'.","invalidDataStructure":"{{elementType}}: In der Methode updateCondition / updateGroup wurde eine ungultige Datenstruktur verwendet.", "dateTabLabel":"DATUM", "timeTabLabel":"ZEIT", "queryLabel":"Abfrage"}}"></smart-query-builder>Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.messages = {"en":{"propertyUnknownType":"'{{name}}' property is with undefined 'type' member!","propertyInvalidValue":"Invalid '{{name}}' property value! Actual value: {{actualValue}}, Expected value: {{value}}!","propertyInvalidValueType":"Invalid '{{name}}' property value type! Actual type: {{actualType}}, Expected type: {{type}}!","elementNotInDOM":"Element does not exist in DOM! Please, add the element to the DOM, before invoking a method.","moduleUndefined":"Module is undefined.","missingReference":"{{elementType}}: Missing reference to {{files}}.","htmlTemplateNotSuported":"{{elementType}}: Browser doesn't support HTMLTemplate elements.","invalidTemplate":"{{elementType}}: '{{property}}' property accepts a string that must match the id of an HTMLTemplate element from the DOM.","add":"Add","addCondition":"Add Condition","addGroup":"Add Group","and":"And","notand":"Not And","or":"Or","notor":"Not Or","=":"Equals","<>":"Does not equal",">":"Greater than",">=":"Greater than or equal to","<":"Less than","<=":"Less than or equal to","startswith":"Starts with","endswith":"Ends with","contains":"Contains","notcontains":"Does not contain","isblank":"Is blank","isnotblank":"Is not blank","wrongParentGroupIndex":"{{elementType}}: Wrong parent group index in '{{method}}' method.","missingFields":"{{elementType}}: Fields are required for proper condition's adding. Set \"fields\" source and then conditions will be added as expected.","wrongElementNode":"{{elementType}}: Incorect node / node Id in '{{method}}' method.","invalidDataStructure":"{{elementType}}: Used invalid data structure in updateCondition/updateGroup method.", "dateTabLabel":"DATE", "timeTabLabel":"TIME", "queryLabel":"Query"}};Read the current value:
const el = document.querySelector('smart-query-builder');
const messages = el.messages;
operatorPlaceholderSpecifies the placeholder text that appears within the operator selection box when no operator has been chosen for the condition. This text guides users by indicating that they need to select an operator.string
Specifies the placeholder text that appears within the operator selection box when no operator has been chosen for the condition. This text guides users by indicating that they need to select an operator.
Default value
"Operator"Examples
Markup and runtime examples for operatorPlaceholder:
HTML:
<smart-query-builder operator-placeholder="Operator not set"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.operatorPlaceholder = "Choose operator...";Read the current value:
const el = document.querySelector('smart-query-builder');
const operatorPlaceholder = el.operatorPlaceholder;
propertyPlaceholderSpecifies the placeholder text displayed within the condition's property field when no field is currently selected by the user. This text provides guidance or prompts users to select a field.string
Specifies the placeholder text displayed within the condition's property field when no field is currently selected by the user. This text provides guidance or prompts users to select a field.
Default value
"Property"Examples
Markup and runtime examples for propertyPlaceholder:
HTML:
<smart-query-builder property-placeholder="Property not set"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.propertyPlaceholder = "Choose property...";Read the current value:
const el = document.querySelector('smart-query-builder');
const propertyPlaceholder = el.propertyPlaceholder;
rightToLeftConfigures or retrieves the value that determines whether the element’s alignment supports right-to-left (RTL) text direction, which is typically used for languages such as Arabic or Hebrew. This property controls whether the element’s layout and text flow are adjusted to accommodate RTL locales.boolean
Configures or retrieves the value that determines whether the element’s alignment supports right-to-left (RTL) text direction, which is typically used for languages such as Arabic or Hebrew. This property controls whether the element’s layout and text flow are adjusted to accommodate RTL locales.
Default value
falseExamples
Markup and runtime examples for rightToLeft:
HTML attribute:
<smart-query-builder right-to-left></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.rightToLeft = false;Read the current value:
const el = document.querySelector('smart-query-builder');
const rightToLeft = el.rightToLeft;
showFieldNameArrowControls the visibility of the dropdown icon associated with the operator field in the conditions section. When enabled, the dropdown icon appears next to the operator field name, allowing users to select an operator from the available options. When disabled, the dropdown icon is hidden, preventing users from opening the operator selection menu.boolean
Controls the visibility of the dropdown icon associated with the operator field in the conditions section. When enabled, the dropdown icon appears next to the operator field name, allowing users to select an operator from the available options. When disabled, the dropdown icon is hidden, preventing users from opening the operator selection menu.
Default value
falseExamples
Markup and runtime examples for showFieldNameArrow:
HTML attribute:
<smart-query-builder show-field-name-arrow></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.showFieldNameArrow = false;Read the current value:
const el = document.querySelector('smart-query-builder');
const showFieldNameArrow = el.showFieldNameArrow;
showIconsControls the visibility of operator icons within the operator selection dropdown menu. When enabled, icons representing each operator are displayed alongside their names in the dropdown list; when disabled, only the operator names are shown without icons.boolean
Controls the visibility of operator icons within the operator selection dropdown menu. When enabled, icons representing each operator are displayed alongside their names in the dropdown list; when disabled, only the operator names are shown without icons.
Default value
falseExamples
Markup and runtime examples for showIcons:
HTML attribute:
<smart-query-builder show-icons></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.showIcons = false;Read the current value:
const el = document.querySelector('smart-query-builder');
const showIcons = el.showIcons;
themeSpecifies the theme to be applied to the element. The theme controls the overall appearance, including colors, fonts, and styling, to ensure a consistent visual presentation throughout the interface.string
Specifies the theme to be applied to the element. The theme controls the overall appearance, including colors, fonts, and styling, to ensure a consistent visual presentation throughout the interface.
Default value
""Examples
Markup and runtime examples for theme:
HTML:
<smart-query-builder theme="blue"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.theme = "red";Read the current value:
const el = document.querySelector('smart-query-builder');
const theme = el.theme;
unfocusableIf set to true, this property prevents the element from receiving keyboard or programmatic focus, making it unable to become the active element within the user interface.boolean
If set to true, this property prevents the element from receiving keyboard or programmatic focus, making it unable to become the active element within the user interface.
Default value
falseExamples
Markup and runtime examples for unfocusable:
HTML attribute:
<smart-query-builder unfocusable></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.unfocusable = false;Read the current value:
const el = document.querySelector('smart-query-builder');
const unfocusable = el.unfocusable;
unlockKeyProvides methods to set or retrieve the 'unlockKey', a unique key required to unlock access to the product. Use this property to assign an unlock key for product activation or to obtain the currently assigned unlock key.string
Provides methods to set or retrieve the 'unlockKey', a unique key required to unlock access to the product. Use this property to assign an unlock key for product activation or to obtain the currently assigned unlock key.
Default value
""Examples
Markup and runtime examples for unlockKey:
HTML:
<smart-query-builder unlock-key=""></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.unlockKey = "1111-2222-3333-4444-5555";Read the current value:
const el = document.querySelector('smart-query-builder');
const unlockKey = el.unlockKey;
validateOnInputSpecifies whether the condition's value should be validated in real-time as the user types (on every key up event) or only when the input field loses focus (on blur), which is the default behavior. If enabled, value validation occurs after the user stops typing, following a delay defined by the validationTimeout property, which sets the time interval (in milliseconds) before triggering validation after typing ceases.boolean
Specifies whether the condition's value should be validated in real-time as the user types (on every key up event) or only when the input field loses focus (on blur), which is the default behavior. If enabled, value validation occurs after the user stops typing, following a delay defined by the validationTimeout property, which sets the time interval (in milliseconds) before triggering validation after typing ceases.
Default value
falseExamples
Markup and runtime examples for validateOnInput:
HTML attribute:
<smart-query-builder validate-on-input></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.validateOnInput = false;Read the current value:
const el = document.querySelector('smart-query-builder');
const validateOnInput = el.validateOnInput;
validationTimeoutSpecifies the delay (in milliseconds) that begins once the user has stopped typing in the value field, after which the condition value is validated. This property works in conjunction with validationOnInput, controlling how soon validation is triggered after user input is complete.number
Specifies the delay (in milliseconds) that begins once the user has stopped typing in the value field, after which the condition value is validated. This property works in conjunction with validationOnInput, controlling how soon validation is triggered after user input is complete.
Default value
100Examples
Markup and runtime examples for validationTimeout:
HTML:
<smart-query-builder validation-timeout="500"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.validationTimeout = 200;Read the current value:
const el = document.querySelector('smart-query-builder');
const validationTimeout = el.validationTimeout;
valueThe value is structured as a multidimensional array, where each top-level element represents a group operator (such as AND or OR) that organizes multiple conditions. Within each group, an array of condition objects specifies the individual filtering criteria. This structure allows for the representation of complex, nested logical expressions by combining multiple groups and conditions. any
The value is structured as a multidimensional array, where each top-level element represents a group operator (such as AND or OR) that organizes multiple conditions. Within each group, an array of condition objects specifies the individual filtering criteria. This structure allows for the representation of complex, nested logical expressions by combining multiple groups and conditions.
Examples
Markup and runtime examples for value:
HTML:
<smart-query-builder value="[[["productCode", "/^\d{7}$/g"], "or", ["id", "isvalid", true]]]"></smart-query-builder>Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.value = [[['available', '=', true], 'and', ['price', '<', 1300],], 'or', [['produced', '>', new Date(2015, 3, 4)], 'and', ['purchased', '>=', new Date(2020, 4, 23, 15, 33)]]];Read the current value:
const el = document.querySelector('smart-query-builder');
const value = el.value;
valueFormatFunctionA callback function that formats the display or value of the condition input fields before they are rendered or processed. Use this to customize how condition values appear to users or are handled within the application.function | null
A callback function that formats the display or value of the condition input fields before they are rendered or processed. Use this to customize how condition values appear to users or are handled within the application.
Examples
Markup and runtime examples for valueFormatFunction:
HTML:
<smart-query-builder value-format-function="function (details) { return details.label + '%'; }"></smart-query-builder>Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.valueFormatFunction = "function (details) { return details.label + '$'; }";Read the current value:
const el = document.querySelector('smart-query-builder');
const valueFormatFunction = el.valueFormatFunction;
valuePlaceholderSpecifies the placeholder text displayed within the condition's value input field when no value has been entered. This text provides guidance or hints to the user about the expected input.string
Specifies the placeholder text displayed within the condition's value input field when no value has been entered. This text provides guidance or hints to the user about the expected input.
Default value
"Value"Examples
Markup and runtime examples for valuePlaceholder:
HTML:
<smart-query-builder value-placeholder="Value not set"></smart-query-builder>
Vanilla JS — prefer #id if multiple widgets exist on the page:
const el = document.querySelector('smart-query-builder');
el.valuePlaceholder = "Choose value...";Read the current value:
const el = document.querySelector('smart-query-builder');
const valuePlaceholder = el.valuePlaceholder;
Events
changeThis event is triggered whenever the value within the query builder is modified by the user, such as adding, editing, or removing rules or conditions. It provides an opportunity to respond to changes in the query configuration, such as validating input, updating results, or synchronizing state with other components.CustomEvent
This event is triggered whenever the value within the query builder is modified by the user, such as adding, editing, or removing rules or conditions. It provides an opportunity to respond to changes in the query configuration, such as validating input, updating results, or synchronizing state with other components.
- Bubbles Yes
- Cancelable No
- Interface CustomEvent
- Event handler property onChange
Arguments
evCustomEvent
ev.detailObject
ev.detail.item - The item that is being dragged.
ev.detail.data - The data of the item that is being dragged.
ev.detail.originalEvent - The original event.
Methods
isDefaultPrevented
Returns true if the event was prevented by any of its subscribers.
Returns
boolean true if the default action was prevented. Otherwise, returns false.
preventDefault
The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.
stopPropagation
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Examples
Listen for change using the pattern that matches your stack.
DOM — listen on the custom element (use a specific selector if the page has more than one):
document.querySelector('smart-query-builder')?.addEventListener('change', (event) => {
const detail = event.detail,
item = detail.item,
data = detail.data,
originalEvent = detail.originalEvent;
// event handling code goes here.
})
dragEndThis event is triggered when a condition that is being dragged is dropped onto a valid target area within the interface. You can prevent the drop action from completing by calling event.preventDefault() within the event handler function. This allows you to implement custom validation or restrict drops based on specific criteria before the condition is accepted.CustomEvent
This event is triggered when a condition that is being dragged is dropped onto a valid target area within the interface. You can prevent the drop action from completing by calling event.preventDefault() within the event handler function. This allows you to implement custom validation or restrict drops based on specific criteria before the condition is accepted.
- Bubbles Yes
- Cancelable Yes
- Interface CustomEvent
- Event handler property onDragEnd
Arguments
evCustomEvent
ev.detailObject
ev.detail.item - The item that is being dragged.
ev.detail.data - The data of the item that is being dragged.
ev.detail.target - The target item.
ev.detail.targetData - the data of the target item.
ev.detail.targetSide - The side of the target item where the dragged item will be dropped.
Methods
isDefaultPrevented
Returns true if the event was prevented by any of its subscribers.
Returns
boolean true if the default action was prevented. Otherwise, returns false.
preventDefault
The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.
stopPropagation
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Examples
Listen for dragEnd using the pattern that matches your stack.
DOM — listen on the custom element (use a specific selector if the page has more than one):
document.querySelector('smart-query-builder')?.addEventListener('dragEnd', (event) => {
const detail = event.detail,
item = detail.item,
data = detail.data,
target = detail.target,
targetData = detail.targetData,
targetSide = detail.targetSide;
// event handling code goes here.
})
draggingThis event is triggered whenever a condition element is actively being dragged within the user interface. It fires continuously throughout the dragging process, allowing developers to track the position and state of the condition as it moves, and to implement custom behaviors—such as visual feedback or dynamic updates—while the drag action is in progress.CustomEvent
This event is triggered whenever a condition element is actively being dragged within the user interface. It fires continuously throughout the dragging process, allowing developers to track the position and state of the condition as it moves, and to implement custom behaviors—such as visual feedback or dynamic updates—while the drag action is in progress.
- Bubbles Yes
- Cancelable Yes
- Interface CustomEvent
- Event handler property onDragging
Arguments
evCustomEvent
ev.detailObject
ev.detail.item - The item that is being dragged.
ev.detail.data - The data of the item that is being dragged.
ev.detail.originalEvent - The original event.
Methods
isDefaultPrevented
Returns true if the event was prevented by any of its subscribers.
Returns
boolean true if the default action was prevented. Otherwise, returns false.
preventDefault
The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.
stopPropagation
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Examples
Listen for dragging using the pattern that matches your stack.
DOM — listen on the custom element (use a specific selector if the page has more than one):
document.querySelector('smart-query-builder')?.addEventListener('dragging', (event) => {
const detail = event.detail,
item = detail.item,
data = detail.data,
originalEvent = detail.originalEvent;
// event handling code goes here.
})
dragStartThis event fires when a drag operation begins within the smart-query-builder component. You can intercept and prevent the drag action from proceeding by calling event.preventDefault() within your event handler. This allows you to implement custom logic or restrictions before the drag operation officially starts.CustomEvent
This event fires when a drag operation begins within the smart-query-builder component. You can intercept and prevent the drag action from proceeding by calling event.preventDefault() within your event handler. This allows you to implement custom logic or restrictions before the drag operation officially starts.
- Bubbles Yes
- Cancelable Yes
- Interface CustomEvent
- Event handler property onDragStart
Arguments
evCustomEvent
ev.detailObject
ev.detail.item - The item is going to be dragged.
ev.detail.data - The data of the item that is going to be dragged.
ev.detail.originalEvent - The original event.
Methods
isDefaultPrevented
Returns true if the event was prevented by any of its subscribers.
Returns
boolean true if the default action was prevented. Otherwise, returns false.
preventDefault
The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.
stopPropagation
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Examples
Listen for dragStart using the pattern that matches your stack.
DOM — listen on the custom element (use a specific selector if the page has more than one):
document.querySelector('smart-query-builder')?.addEventListener('dragStart', (event) => {
const detail = event.detail,
item = detail.item,
data = detail.data,
originalEvent = detail.originalEvent;
// event handling code goes here.
})
itemClickThis event is triggered whenever a user interacts with any component of the query builder—such as selecting an operator, clicking on a field name, entering a value, or pressing the close button. It allows you to respond to user actions on any of the query builder’s building blocks.CustomEvent
This event is triggered whenever a user interacts with any component of the query builder—such as selecting an operator, clicking on a field name, entering a value, or pressing the close button. It allows you to respond to user actions on any of the query builder’s building blocks.
- Bubbles Yes
- Cancelable No
- Interface CustomEvent
- Event handler property onItemClick
Arguments
evCustomEvent
ev.detailObject
ev.detail.id - The internal id of the clicked item, e.g. '0.1', '1.1', etc.
ev.detail.type - The type of the clicked item ( condition or a group ).
ev.detail.data - The data of the item.
Methods
isDefaultPrevented
Returns true if the event was prevented by any of its subscribers.
Returns
boolean true if the default action was prevented. Otherwise, returns false.
preventDefault
The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.
stopPropagation
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Examples
Listen for itemClick using the pattern that matches your stack.
DOM — listen on the custom element (use a specific selector if the page has more than one):
document.querySelector('smart-query-builder')?.addEventListener('itemClick', (event) => {
const detail = event.detail,
id = detail.id,
type = detail.type,
data = detail.data;
// event handling code goes here.
})
propertySelectedThis event is triggered when a user selects a specific field, indicating that the field has become active or has received focus. It can be used to initiate actions such as loading related data, displaying contextual hints, or tracking user interactions with the form element.CustomEvent
This event is triggered when a user selects a specific field, indicating that the field has become active or has received focus. It can be used to initiate actions such as loading related data, displaying contextual hints, or tracking user interactions with the form element.
- Bubbles Yes
- Cancelable No
- Interface CustomEvent
- Event handler property onPropertySelected
Arguments
evCustomEvent
ev.detailObject
ev.detail.label - The label of the selected property.
ev.detail.value - The value of the selected property.
Methods
isDefaultPrevented
Returns true if the event was prevented by any of its subscribers.
Returns
boolean true if the default action was prevented. Otherwise, returns false.
preventDefault
The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.
stopPropagation
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Examples
Listen for propertySelected using the pattern that matches your stack.
DOM — listen on the custom element (use a specific selector if the page has more than one):
document.querySelector('smart-query-builder')?.addEventListener('propertySelected', (event) => {
const detail = event.detail,
label = detail.label,
value = detail.value;
// event handling code goes here.
})
validationChangeThis event is triggered whenever the component performs input validation. Validation occurs each time a user enters a new value and then shifts focus away from the component (for example, by clicking or tabbing to another UI element). The event provides an opportunity to respond to changes in the input’s validity, such as displaying error messages or updating related state.CustomEvent
This event is triggered whenever the component performs input validation. Validation occurs each time a user enters a new value and then shifts focus away from the component (for example, by clicking or tabbing to another UI element). The event provides an opportunity to respond to changes in the input’s validity, such as displaying error messages or updating related state.
- Bubbles Yes
- Cancelable No
- Interface CustomEvent
- Event handler property onValidationChange
Arguments
evCustomEvent
ev.detailObject
ev.detail.oldValue - Old validation status.
ev.detail.newValue - New validation status.
Methods
isDefaultPrevented
Returns true if the event was prevented by any of its subscribers.
Returns
boolean true if the default action was prevented. Otherwise, returns false.
preventDefault
The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.
stopPropagation
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Examples
Listen for validationChange using the pattern that matches your stack.
DOM — listen on the custom element (use a specific selector if the page has more than one):
document.querySelector('smart-query-builder')?.addEventListener('validationChange', (event) => {
const detail = event.detail,
oldValue = detail.oldValue,
newValue = detail.newValue;
// event handling code goes here.
})
Methods
getLinq(): stringTransforms the element's current value into a valid Dynamic LINQ expression, enabling advanced querying and runtime evaluation based on the element's data.
Transforms the element's current value into a valid Dynamic LINQ expression, enabling advanced querying and runtime evaluation based on the element's data.
Returnsstring
On the custom element in the DOM (narrow the selector, e.g. to #my-querybuilder, if you host multiple widgets):
const result = document.querySelector('smart-query-builder')?.getLinq();
Try a demo showcasing the getLinq method.
CSS Variables
--smart-query-builder-default-widthvar()
Default value
"auto"Default width of QueryBuilder.
--smart-query-builder-default-heightvar()
Default value
"auto"Default height of QueryBuilder.
--smart-query-builder-min-widthvar()
Default value
"100px"Minimum width of QueryBuilder.
--smart-query-builder-content-paddingvar()
Default value
"5px"Padding of QueryBuilder.
--smart-query-builder-editor-widthvar()
Default value
"125px"Width of editors in QueryBuilder.