QueryBuilder JAVASCRIPT UI Component API

QueryBuilder Javascript API

Class

QueryBuilder

QueryBuilder allows you to build dynamically queries for filtering.

Selector

smart-query-builder

Properties

Events

Methods

Properties

allowDragboolean

Enables the dragging of conditions inside a group or between groups.

Default value

false

Example

Set the allowDrag property.

 <smart-query-builder allow-drag></smart-query-builder>

Set the allowDrag property by using the HTML Element's instance.

 const querybuilder = document.querySelector('smart-query-builder');
 querybuilder.allowDrag = false;

Get the allowDrag property.

 const querybuilder = document.querySelector('smart-query-builder');
 let allowDrag = querybuilder.allowDrag;

animation"none" | "simple" | "advanced"

Sets or gets the animation mode. Animation is disabled when the property is set to 'none'

Default value

"advanced"

Example

Set the animation property.

 <smart-query-builder animation='none'></smart-query-builder>

Set the animation property by using the HTML Element's instance.

 const querybuilder = document.querySelector('smart-query-builder');
 querybuilder.animation = 'simple';

Get the animation property.

 const querybuilder = document.querySelector('smart-query-builder');
 let animation = querybuilder.animation;

applyMode"change" | "immediately"

Determines when the value of the element is updated with the new changes.

Default value

"change"

Example

Set the applyMode property.

 <smart-query-builder apply-mode='immediately'></smart-query-builder>

Set the applyMode property by using the HTML Element's instance.

 const querybuilder = document.querySelector('smart-query-builder');
 querybuilder.applyMode = 'change';

Get the applyMode property.

 const querybuilder = document.querySelector('smart-query-builder');
 let applyMode = querybuilder.applyMode;

customOperations{label: string, name: string, editorTemplate: function, valueTemplate: function, handleValue: function, hideValue: boolean, expressionTemplate: string, expressionReaderCallback: function, expressionBuilderCallback: function}[]

Adds more operations that can be used to the query bilder's conditions structure. Each custom operation can have the following fields:

  • label - label to be displayed in the operator box. Multiple operations with the same label can exist.
  • name - unique name of the operation
  • editorTemplate - callback function that creates a custom value editor
  • valueTemplate - callback function that displays the value after the edior has been closed
  • handleValue - callback function that handles the value returned by the editor when it is closed
  • hideValue - a boolean condition that specifies whether the operation requires a value or not
  • expressionTemplate - 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 - 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.
  • expressionBuilderCallback - 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.

Example

Set the customOperations property.

 <smart-query-builder custom-operations='[{ label: "Matches /^\d{7}$/g", name: "/^\d{7}$/g", hideValue: true }, { label: "Similar to", name: "similar" }]'></smart-query-builder>

Set the customOperations property by using the HTML Element's instance.

 const querybuilder = document.querySelector('smart-query-builder');
 querybuilder.customOperations = [{ label: 'Is valid', name: 'isvalid' }];

Get the customOperations property.

 const querybuilder = document.querySelector('smart-query-builder');
 let customOperations = querybuilder.customOperations;

disabledboolean

Enables or disables the element.

Default value

false

Example

Set the disabled property.

 <smart-query-builder disabled></smart-query-builder>

Set the disabled property by using the HTML Element's instance.

 const querybuilder = document.querySelector('smart-query-builder');
 querybuilder.disabled = false;

Get the disabled property.

 const querybuilder = document.querySelector('smart-query-builder');
 let disabled = querybuilder.disabled;

dropDownWidthstring

Sets or gets the dropdown width of the property and operator editors.

Default value

"100%"

Example

Set the dropDownWidth property.

 <smart-query-builder drop-down-width='300'></smart-query-builder>

Set the dropDownWidth property by using the HTML Element's instance.

 const querybuilder = document.querySelector('smart-query-builder');
 querybuilder.dropDownWidth = '80%';

Get the dropDownWidth property.

 const querybuilder = document.querySelector('smart-query-builder');
 let dropDownWidth = querybuilder.dropDownWidth;

fields{label: string, dataField: string, dataType: string, dataType: string, format: any, filterOperations: string[]}[]

Array with filter fields and their settings. The available field settings are:

  • label - the field's label, as it will appear in the field selection drop down
  • dataField - the field's data field
  • dataType - the field's data type
  • filterOperations - an array of the filter operations applicable to the field; if not set, the default filter operations are applied
  • lookup - an object with settings for customizing the field's respective value selection input. It has the following settings:
    • autoCompleteDelay - delay between typing in the input and opening the drop down with available options
    • dataSource - an array of available options to choose from (appear in a drop down)
    • minLength - minimum number of charactes to type in the input before the options drop down is displayed
    • readonly - if set to true, the value selection input acts as a drop down list, otherwise it acts as a combo box

    Example

    Set the fields property.

     <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>

    Set the fields property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.fields = [{ "label": "id", "dataField": "id", "dataType": "number", "format": null, "filterOperations": ["=", "anyof"] }, { "label": "Product", "dataField": "productName", "dataType": "string", "format": null }];

    Get the fields property.

     const querybuilder = document.querySelector('smart-query-builder');
     let fields = querybuilder.fields;

    fieldsMode"dynamic" | "static"

    Determines whether new fields can be dynamically added by typing in the field (property) box.

    Default value

    "dynamic"

    Example

    Set the fieldsMode property.

     <smart-query-builder fields-mode='static'></smart-query-builder>

    Set the fieldsMode property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.fieldsMode = 'dynamic';

    Get the fieldsMode property.

     const querybuilder = document.querySelector('smart-query-builder');
     let fieldsMode = querybuilder.fieldsMode;

    formatStringDatestring

    Sets or gets the format string of the editor of fields with type 'date'.

    Default value

    "dd-MMM-yy"

    Example

    Set the formatStringDate property.

     <smart-query-builder format-string-date='dddd-MMMM-yyyy'></smart-query-builder>

    Set the formatStringDate property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.formatStringDate = 'M/d/yyyy';

    Get the formatStringDate property.

     const querybuilder = document.querySelector('smart-query-builder');
     let formatStringDate = querybuilder.formatStringDate;

    formatStringDateTimestring

    Sets or gets the format string of the editor of fields with type 'dateTime'.

    Default value

    "dd-MMM-yy HH:mm:ss"

    Example

    Set the formatStringDateTime property.

     <smart-query-builder format-string-date-time='h:mm:ss tt'></smart-query-builder>

    Set the formatStringDateTime property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.formatStringDateTime = 'yyyy-MM-dd hh:mm:ss';

    Get the formatStringDateTime property.

     const querybuilder = document.querySelector('smart-query-builder');
     let formatStringDateTime = querybuilder.formatStringDateTime;

    getDynamicFieldfunction | null

    A callback function called when a field is added dynamically. Used for configuring settings of the new field. Applicable only when fieldsMode is 'dynamic'.

    Example

    Set the getDynamicField property.

     <smart-query-builder get-dynamic-field='getDynamicFieldFunction'></smart-query-builder>

    Set the getDynamicField property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.getDynamicField = function (field) { return { dataField: field.toLowerCase(), dataType: 'number', filterOperations: ['<', '>'] }; };

    Get the getDynamicField property.

     const querybuilder = document.querySelector('smart-query-builder');
     let getDynamicField = querybuilder.getDynamicField;

    iconsany

    Defines CSS classes to be applied to each of the built-in operations. Icons for these classes are applied in the smart-query-builder style sheet. This property is applicable only if showIcons is set to true.

    Default value

    { '=': 'equals', '<>': 'notequals', '>': 'greaterthan', '>=': 'greaterthanorequal', '<': 'lessthan', '<=': 'lessthanorequal', 'startswith': 'startswith', 'endswith': 'endswith', 'contains': 'contains', 'notcontains': 'notcontains', 'isblank': 'isblank', 'isnotblank': 'isnotblank' }

    Example

    Set the icons property.

     <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>

    Set the icons property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.icons = { '=': 'equals', '<>': 'notequals', '>': 'greaterthan', '>=': 'greaterthanorequal', '<': 'lessthan', '<=': 'lessthanorequal', 'startswith': 'startswith', 'endswith': 'endswith', 'contains': 'contains', 'notcontains': 'notcontains', 'isblank': 'blank', 'isnotblank': 'notblank' };

    Get the icons property.

     const querybuilder = document.querySelector('smart-query-builder');
     let icons = querybuilder.icons;

    localestring

    Sets or gets the language. Used in conjunction with the property messages.

    Default value

    "en"

    Example

    Set the locale property.

     <smart-query-builder locale='de'></smart-query-builder>

    Set the locale property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.locale = 'fr';

    Get the locale property.

     const querybuilder = document.querySelector('smart-query-builder');
     let locale = querybuilder.locale;

    localizeFormatFunctionfunction | null

    Callback used to customize the format of the messages that are returned from the Localization Module.

    Example

    Set the localizeFormatFunction property.

     <smart-query-builder localize-format-function='function(defaultMessage, message, messageArguments){return '...'}'></smart-query-builder>

    Set the localizeFormatFunction property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.localizeFormatFunction = function(defaultMessage, message, messageArguments){return '...'};

    Get the localizeFormatFunction property.

     const querybuilder = document.querySelector('smart-query-builder');
     let localizeFormatFunction = querybuilder.localizeFormatFunction;

    messagesobject

    Defines field names of the filtered element.

    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.",

    "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."

    }

    Example

    Set the messages property.

     <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.","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."}}'></smart-query-builder>

    Set the messages property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.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.","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."}};

    Get the messages property.

     const querybuilder = document.querySelector('smart-query-builder');
     let messages = querybuilder.messages;

    operatorPlaceholderstring

    Determines the placeholder text used inside the condition's operator box in case an operator is not selected.

    Default value

    "Operator"

    Example

    Set the operatorPlaceholder property.

     <smart-query-builder operator-placeholder='Operator not set'></smart-query-builder>

    Set the operatorPlaceholder property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.operatorPlaceholder = 'Choose operator...';

    Get the operatorPlaceholder property.

     const querybuilder = document.querySelector('smart-query-builder');
     let operatorPlaceholder = querybuilder.operatorPlaceholder;

    propertyPlaceholderstring

    Determines the placeholder text used inside the condition's field (property) box in case a field is not selected.

    Default value

    "Property"

    Example

    Set the propertyPlaceholder property.

     <smart-query-builder property-placeholder='Property not set'></smart-query-builder>

    Set the propertyPlaceholder property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.propertyPlaceholder = 'Choose property...';

    Get the propertyPlaceholder property.

     const querybuilder = document.querySelector('smart-query-builder');
     let propertyPlaceholder = querybuilder.propertyPlaceholder;

    rightToLeftboolean

    Sets or gets the value indicating whether the element is aligned to support locales using right-to-left fonts.

    Default value

    false

    Example

    Set the rightToLeft property.

     <smart-query-builder right-to-left></smart-query-builder>

    Set the rightToLeft property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.rightToLeft = false;

    Get the rightToLeft property.

     const querybuilder = document.querySelector('smart-query-builder');
     let rightToLeft = querybuilder.rightToLeft;

    showIconsboolean

    Shows/Hides the operator icons shown in the operator selection drop down.

    Default value

    false

    Example

    Set the showIcons property.

     <smart-query-builder show-icons></smart-query-builder>

    Set the showIcons property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.showIcons = false;

    Get the showIcons property.

     const querybuilder = document.querySelector('smart-query-builder');
     let showIcons = querybuilder.showIcons;

    themestring

    Determines the theme. Theme defines the look of the element

    Default value

    ""

    Example

    Set the theme property.

     <smart-query-builder theme='blue'></smart-query-builder>

    Set the theme property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.theme = 'red';

    Get the theme property.

     const querybuilder = document.querySelector('smart-query-builder');
     let theme = querybuilder.theme;

    unfocusableboolean

    If is set to true, the element cannot be focused.

    Default value

    false

    Example

    Set the unfocusable property.

     <smart-query-builder unfocusable></smart-query-builder>

    Set the unfocusable property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.unfocusable = false;

    Get the unfocusable property.

     const querybuilder = document.querySelector('smart-query-builder');
     let unfocusable = querybuilder.unfocusable;

    valueany

    The value is represented by multidimensional array. The array contains group operators with conditions. Each group can contain multiple conditions.

    Example

    Set the value property.

     <smart-query-builder value='[[["productCode", "/^\d{7}$/g"], "or", ["id", "isvalid", true]]]'></smart-query-builder>

    Set the value property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.value = [[['available', '=', true], 'and', ['price', '<', 1300],], 'or', [['produced', '>', new Date(2015, 3, 4)], 'and', ['purchased', '>=', new Date(2020, 4, 23, 15, 33)]]];

    Get the value property.

     const querybuilder = document.querySelector('smart-query-builder');
     let value = querybuilder.value;

    valueFormatFunctionfunction | null

    Callback used to format the content of the value fields.

    Example

    Set the valueFormatFunction property.

     <smart-query-builder value-format-function='function (value) { return value + '%'; }'></smart-query-builder>

    Set the valueFormatFunction property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.valueFormatFunction = function (value) { return value + '$'; };

    Get the valueFormatFunction property.

     const querybuilder = document.querySelector('smart-query-builder');
     let valueFormatFunction = querybuilder.valueFormatFunction;

    valuePlaceholderstring

    Determines the placeholder text used inside the condition's value box in case a value is not set.

    Default value

    "Value"

    Example

    Set the valuePlaceholder property.

     <smart-query-builder value-placeholder='Value not set'></smart-query-builder>

    Set the valuePlaceholder property by using the HTML Element's instance.

     const querybuilder = document.querySelector('smart-query-builder');
     querybuilder.valuePlaceholder = 'Choose value...';

    Get the valuePlaceholder property.

     const querybuilder = document.querySelector('smart-query-builder');
     let valuePlaceholder = querybuilder.valuePlaceholder;

    Events

    changeCustomEvent

    This event is triggered when the query builder's value is changed.

    • 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.

    Example

    Set up the event handler of change event.

    const querybuilder = document.querySelector('smart-query-builder');
    querybuilder.addEventListener('change', function (event) {
        const detail = event.detail,
            item = detail.item,
            data = detail.data,
            originalEvent = detail.originalEvent;
    
    	// event handling code goes here.
    })
    

    dragEndCustomEvent

    This event is triggered when a dragged condition is dropped. This action can be canceled by calling event.preventDefault() in the event handler function.

    • 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.

    Example

    Set up the event handler of dragEnd event.

    const querybuilder = document.querySelector('smart-query-builder');
    querybuilder.addEventListener('dragEnd', function (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.
    })
    

    draggingCustomEvent

    This event is triggered when a condition is being dragged.

    • 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.

    Example

    Set up the event handler of dragging event.

    const querybuilder = document.querySelector('smart-query-builder');
    querybuilder.addEventListener('dragging', function (event) {
        const detail = event.detail,
            item = detail.item,
            data = detail.data,
            originalEvent = detail.originalEvent;
    
    	// event handling code goes here.
    })
    

    dragStartCustomEvent

    This event is triggered when a dragging operation is started in smart-query-builder. This action can be canceled by calling event.preventDefault() in the event handler function.

    • 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.

    Example

    Set up the event handler of dragStart event.

    const querybuilder = document.querySelector('smart-query-builder');
    querybuilder.addEventListener('dragStart', function (event) {
        const detail = event.detail,
            item = detail.item,
            data = detail.data,
            originalEvent = detail.originalEvent;
    
    	// event handling code goes here.
    })
    

    itemClickCustomEvent

    This event is triggered when one of the query builder's building blocks ( oeprator, fieldName, value, close button, etc) is clicked.

    • 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.

    Example

    Set up the event handler of itemClick event.

    const querybuilder = document.querySelector('smart-query-builder');
    querybuilder.addEventListener('itemClick', function (event) {
        const detail = event.detail,
            id = detail.id,
            type = detail.type,
            data = detail.data;
    
    	// event handling code goes here.
    })
    

    propertySelectedCustomEvent

    This event is triggered when a field has been selected.

    • 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.

    Example

    Set up the event handler of propertySelected event.

    const querybuilder = document.querySelector('smart-query-builder');
    querybuilder.addEventListener('propertySelected', function (event) {
        const detail = event.detail,
            label = detail.label,
            value = detail.value;
    
    	// event handling code goes here.
    })
    

    Methods

    getLinq(): string

    Converts the current value of the element to DynamicLINQ expression.

    Returnsstring

    Invoke the getLinq method.

    const querybuilder = document.querySelector('smart-query-builder');
    const result = querybuilder.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.