DevExtreme Vue - Selection

API

The selection capability is not provided out of the box, but it can be implemented using the onItemClick event handler. The following code gives an example for the scenario when a click on a funnel item selects it, and a subsequent click on the same item clears the selection. To check whether the funnel item is already selected, its isSelected() method is called.

jQuery
JavaScript
$(function() {
    $("#funnelContainer").dxFunnel({
        // ...
        onItemClick: function (e) {
            e.item.select(!e.item.isSelected())
        }
    });
});
Angular
HTML
TypeScript
<dx-funnel
    (onItemClick)="onItemClick($event)">
</dx-funnel>
import { DxFunnelModule } from "devextreme-angular";
// ...
export class AppComponent {
    onItemClick (e) {
        e.item.select(!e.item.isSelected())
    };
}
@NgModule({
    imports: [
        // ...
        DxFunnelModule
    ],
    // ...
})

In the previous code example, selection was cleared of a specific item. If you need to clear selection of all items, call the Funnel's clearSelection() method.

jQuery
JavaScript
$("#funnelContainer").dxFunnel("clearSelection");
Angular
TypeScript
import { ..., ViewChild } from "@angular/core";
import { DxFunnelModule, DxFunnelComponent } from "devextreme-angular";
// ...
export class AppComponent {
    @ViewChild(DxFunnelComponent) funnel: DxFunnelComponent;
    clearSelection() {
        this.funnel.instance.clearSelection();
    }
}
@NgModule({
    imports: [
        // ...
        DxFunnelModule
    ],
    // ...
})
See Also

User Interaction

When a user selects funnel items, they change their style to the one specified by the item.selectionStyle object.

jQuery
JavaScript
$(function() {
    $("#funnelContainer").dxFunnel({
        // ...
        item: {
            selectionStyle: {
                hatching: { direction: "left" }
            }
        }
    });
});
Angular
HTML
TypeScript
<dx-funnel ... >
    <dxo-item>
        <dxo-selection-style>
            <dxo-hatching direction="left"></dxo-hatching>
        </dxo-selection-style>
    </dxo-item>
</dx-funnel>
import { DxFunnelModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxFunnelModule
    ],
    // ...
})

Events

When a funnel item's selection state is being changed, the Funnel raises the selectionChanged event that you can handle with a function. If the handling function is not going to be changed during the lifetime of the widget, assign it to the onSelectionChanged option when you configure the widget. To check whether a funnel item was selected or the selection was cleared, call the item's isSelected() method.

jQuery
JavaScript
$(function() {
    $("#funnelContainer").dxFunnel({
        // ...
        onSelectionChanged: function (e) {
            if (e.item.isSelected()) {
                // Commands to execute when the item is selected
            } else {
                // Commands to execute when the selection is cleared
            }
        }
    });
});
Angular
HTML
JavaScript
<dx-funnel ...
    (onSelectionChanged)="onSelectionChanged($event)">
</dx-funnel>
import { DxFunnelModule } from "devextreme-angular";
// ...
export class AppComponent {
    onSelectionChanged (e) {
        if (e.item.isSelected()) {
            // Commands to execute when the item is selected
        } else {
            // Commands to execute when the selection is cleared
        }
    };
}
@NgModule({
    imports: [
        // ...
        DxFunnelModule
    ],
    // ...
})

If you are going to change the event handler at runtime, or if you need to attach several handlers to the selectionChanged event, subscribe to this event using the on(eventName, eventHandler) method. This approach is more typical of jQuery.

JavaScript
var selectionChangedHandler1 = function (e) {
    // First handler of the "selectionChanged" event
};

var selectionChangedHandler2 = function (e) {
    // Second handler of the "selectionChanged" event
};

$("#funnelContainer").dxFunnel("instance")
    .on("selectionChanged", selectionChangedHandler1)
    .on("selectionChanged", selectionChangedHandler2);
See Also