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

customOperations[]

Configures custom filter operations.

Default Value: []

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: {}
jQuery
$(function(){
    $("#filterBuilderContainer").dxFilterBuilder({
        // ...
        elementAttr: {
            id: "elementId",
            class: "class-name"
        }
    });
});
Angular
HTML
TypeScript
<dx-filter-builder ...
    [elementAttr]="{ id: 'elementId', class: 'class-name' }">
</dx-filter-builder>
import { DxFilterBuilderModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxFilterBuilderModule
    ],
    // ...
})
ASP.NET MVC Control
Razor C#
Razor VB
@(Html.DevExtreme().FilterBuilder()
    .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().FilterBuilder() _
    .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 function that is executed before the widget is disposed of.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FilterBuilder

The widget's instance.

element

Element (jQuery or HTML)

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 function that is executed after an editor is created.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FilterBuilder

The widget's instance.

element

Element (jQuery or HTML)

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 field's value after the editor's value changes.

editorElement

Element (jQuery or HTML)

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.

filterOperation

String

The applied filter operation.

updateValueTimeout

Number

Gets and sets the delay between when a user stops typing the field's 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 function.

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

onEditorPreparing

A function that is executed before an editor is created.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FilterBuilder

The widget's instance.

element

Element (jQuery or HTML)

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 field's value after the editor's value changes.

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

Element (jQuery or HTML)

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.

filterOperation

String

The applied filter operation.

updateValueTimeout

Number

Gets and sets the delay between when a user stops typing the 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 different editors for entering a value depending on the field's dataType: Calendar, TextBox, SelectBox, and so on. Use this function to customize those default editors or substitute them for other editors.

In the following code, a default editor is replaced with the DevExtreme TextArea widget. Note that the widget's onValueChanged function is overridden, and its declaration ends with the setValue(newValue, newText) method's call. This method updates the value.

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

The following code shows how to replace a default editor with a non-DevExtreme editor (an HTML checkbox in this case):

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

onInitialized

A function that is executed only once, after the widget is initialized.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FilterBuilder

The widget's instance.

element

Element (jQuery or HTML)

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 function because it is executed before they are ready.

onOptionChanged

A function that is executed after a widget option is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FilterBuilder

The widget's instance.

name

String

The option's short name.

fullName

String

The option's full name.

value any

The option's new value.

element

Element (jQuery or HTML)

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

onValueChanged

A function that is executed after the widget's value is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FilterBuilder

The widget's instance.

element

Element (jQuery or HTML)

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

Allows you to specify a filter.

Default Value: null
Raised Events: valueChanged
NOTE
This option may contain filter operations that the DataSource does not support. Use the getFilterExpression method to get the DataSource-compatible filter expression.
See Also

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