Configuration

An object defining the FilterBuilder widget's configuration options.

accessKey

Specifies the shortcut key that sets focus on the widget.

Type:

String

Default Value: null

The value of this option will be passed to the accesskey attribute of the HTML element that underlies the widget.

activeStateEnabled

Specifies whether or not the widget changes its state when interacting with a user.

Type:

Boolean

Default Value: false

This option is used when the widget is displayed on a platform whose guidelines include the active state change for widgets.

allowHierarchicalFields

Specifies whether the widget can display hierarchical data fields.

Type:

Boolean

Default Value: false

disabled

Specifies whether the widget responds to user interaction.

Type:

Boolean

Default Value: false

elementAttr

Specifies the attributes to be attached to the widget's root element.

Type:

Object

Default Value: {}

You can configure this option in an ASP.NET MVC Control as follows:

Razor C#
Razor VB
@(Html.DevExtreme().WidgetName()
    .ElementAttr("class", "class-name")
    // ===== or =====
    .ElementAttr(new {
        @id = "elementId",
        @class = "class-name"
    })
    // ===== or =====
    .ElementAttr(new Dictionary<string, object>() {
        { "id", "elementId" },
        { "class", "class-name" }
    })

)
@(Html.DevExtreme().WidgetName() _
    .ElementAttr("class", "class-name")
    ' ===== or =====
    .ElementAttr(New With {
        .id = "elementId",
        .class = "class-name"
    })
    ' ===== or =====
    .ElementAttr(New Dictionary(Of String, Object) From {
        { "id", "elementId" },
        { "class", "class-name" }
    })
)

fields

Configures fields.

Default Value: []

This option accepts an array of objects, each configuring a filter condition's appearance. Each condition consists of a data field, operation and value. A logical operation can combine conditions on the same level in a group.

DevExtreme HTML5 JavaScript Filter Builder Fields

See the Field section for details on fields you can specify in each object.

View Demo

filterOperationDescriptions

Specifies filter operation descriptions.

Type:

Object

focusStateEnabled

Specifies whether the widget can be focused using keyboard navigation.

Type:

Boolean

Default Value: false

groupOperationDescriptions

Specifies group operation descriptions.

Type:

Object

height

Specifies the widget's height.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The widget's height.

Default Value: undefined

This option accepts a value of one of the following types:

  • Number
    The height in pixels.

  • String
    A CSS-accepted measurement of height. For example, "55px", "80%", "auto", "inherit".

  • Function
    A function returning either of the above. For example:

    JavaScript
    height: function() {
        return window.innerHeight / 1.5;
    }

hint

Specifies text for a hint that appears when a user pauses on the widget.

Type:

String

Default Value: undefined

hoverStateEnabled

Specifies whether the widget changes its state when a user pauses on it.

Type:

Boolean

Default Value: false

onDisposing

A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Object

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

The model data. Available only if you use Knockout.

Default Value: null

onEditorPrepared

A handler for the editorPrepared event. Executed after an editor is created.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Object

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

The model data. Available only if you use Knockout.

value any

The editor's value.

setValue(newValue) any

A method that you need to call to change the data field's value after the editor's value is changed.

editorElement

HTMLElement | jQuery

The editor's container. It is an HTML Element or a jQuery Element when you use jQuery.

editorName

String

The editor's name.

dataField

String

The data field's name.

updateValueTimeout

Number

Gets and sets the delay between when a user stops typing a field value and when it is applied.

width

Number

The editor's width.

readOnly

Boolean

Indicates whether the editor is read-only.

disabled

Boolean

Indicates whether the editor is disabled.

rtlEnabled

Boolean

Indicates whether the editor uses right-to-left representation.

Default Value: null

The widget offers a user a different editor for entering a value depending on the field's dataType: Calendar, TextBox, SelectBox, etc. You can customize automatically created editors using this handler.

NOTE
This handler is not executed for fields that use the editorTemplate.

onEditorPreparing

A handler for the editorPreparing event. Executed before an editor is created.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Object

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

The model data. Available only if you use Knockout.

value any

The editor's value.

setValue(newValue) any

A method that you should call to change the data field's value after the editor's value is changed.

cancel

Boolean

Allows you to cancel the creation of the editor.
Set it to true and implement a custom editor if your scenario requires it.

editorElement

HTMLElement | jQuery

The editor's container. It is an HTML Element or a jQuery Element when you use jQuery.

editorName

String

Allows you to change the editor. Accepts names of DevExtreme widgets only, for example, "dxTextBox".
Import a new editor's module when using DevExtreme modules.

editorOptions

Object

Gets and sets the editor configuration.

dataField

String

The data field's name.

updateValueTimeout

Number

Gets and sets the delay between when a user stops typing a field value and when it is applied.

width

Number

The editor's width.

readOnly

Boolean

Indicates whether the editor is read-only.

disabled

Boolean

Indicates whether the editor is disabled.

rtlEnabled

Boolean

Indicates whether the editor uses right-to-left representation.

Default Value: null

The widget offers a user a different editor for entering a value depending on the field's dataType: Calendar, TextBox, SelectBox, etc. Within this handler, you can customize a default editor or substitute it for another DevExtreme editor. To do the latter, assign the editor's name to the editorName field and then configure the editor in the editorOptions object. If you specify the editor's onValueChanged handler, call the setValue(newValue) method in it to update the value.

jQuery
JavaScript
$(function() {
    $("#filterBuilder").dxFilterBuilder({
        // ...
        onEditorPreparing: function(e) {
            if (e.dataField == "name") {
                e.editorName = "dxTextArea";
                e.editorOptions.showClearButton = true;
                e.editorOptions.onValueChanged = function (e) {
                    var value = e.value;
                    if(value == "") {
                        alert("TextArea is empty");
                        return;
                    }
                    e.setValue(value);
                }
            }
        }
    });
});
Angular
TypeScript
HTML
import { DxFilterBuilderModule } from 'devextreme-angular';
// ...
export class AppComponent {
    onEditorPreparing (e) { 
        if (e.dataField == "name") {
            e.editorName = "dxTextArea";
            e.editorOptions.showClearButton = true;
            e.editorOptions.onValueChanged = function (e) {
                var value = e.value;
                if (value == "") {
                    alert("TextArea is empty");
                    return;
                }
                e.setValue(value);
            }
        }
    }
}
@NgModule({
    imports: [
        // ...
        DxFilterBuilderModule
    ],
    // ...
})
<dx-filter-builder ...
    (onEditorPreparing)="onEditorPreparing($event)">
</dx-filter-builder>

If you use a third-party editor, cancel the default editor creation and then implement your one. Call the setValue(newValue) method in the onEditorPreparing handler to notify the FilterBuilder of the changed value.

jQuery
JavaScript
$(function() {
    $("#filterBuilder").dxFilterBuilder({
        // ...
        onEditorPreparing: function(e) {
            if(e.dataField === "hidden") {
                e.cancel = true;
                $('<input type="checkbox">')
                    .prop("checked", e.value)
                    .on("change", function(args) {
                        e.setValue(args.target.checked);
                    })
                    .appendTo(e.editorElement);
            }
        }
    });
});
Angular
TypeScript
HTML
import { DxFilterBuilderModule } from 'devextreme-angular';
// ...
export class AppComponent {
    onEditorPreparing (e) { 
        if(e.dataField === "hidden") {
            e.cancel = true;
            let checkbox = document.createElement("INPUT");
            checkbox.setAttribute("type", "checkbox");
            checkbox.setAttribute("checked", e.value);
            checkbox.addEventListener("change", function(args) {
                                                    e.setValue(args.target.checked);
                                                });
            e.editorElement.appendChild(checkbox);
        }
    }
}
@NgModule({
    imports: [
        // ...
        DxFilterBuilderModule
    ],
    // ...
})
<dx-filter-builder ...
    (onEditorPreparing)="onEditorPreparing($event)">
</dx-filter-builder>
NOTE
This handler is not executed for fields that use the editorTemplate.

onInitialized

A handler for the initialized event. Executed only once, after the widget is initialized.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Object

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

Default Value: null

You cannot access widget elements in this handler because it is executed before they are ready.

onOptionChanged

A handler for the optionChanged event. Executed after an option of the widget is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
name

String

The option's short name.

model

Object

The model data. Available only if you use Knockout.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

component

Object

The widget's instance.

fullName

String

The option's full name.

value any

The option's new value.

Default Value: null

onValueChanged

A handler for the valueChanged event. Executed after the widget's value is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

Object

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

The model data. Available only if you use Knockout.

value

Object

The widget's new value.

previousValue

Object

The widget's previous value.

Default Value: null

rtlEnabled

Switches the widget to a right-to-left representation.

Type:

Boolean

Default Value: false

When this option is set to true, the widget text flows from right to left, and the layout of elements is reversed. To switch the entire application/site to the right-to-left representation, assign true to the rtlEnabled field of the object passed to the DevExpress.config(config) method.

JavaScript
DevExpress.config({
    rtlEnabled: true
});
See Also

tabIndex

Specifies the number of the element when the Tab key is used for navigating.

Type:

Number

Default Value: 0

The value of this option will be passed to the tabindex attribute of the HTML element that underlies the widget.

value

Specifies the current filter expression.

Default Value: null

visible

Specifies whether the widget is visible.

Type:

Boolean

Default Value: true

width

Specifies the widget's width.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The widget's width.

Default Value: undefined

This option accepts a value of one of the following types:

  • Number
    The width in pixels.

  • String
    A CSS-accepted measurement of width. For example, "55px", "80%", "auto", "inherit".

  • Function
    A function returning either of the above. For example:

    JavaScript
    width: function() {
        return window.innerWidth / 1.5;
    }