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.
- $(function() {
- $("#funnelContainer").dxFunnel({
- // ...
- onItemClick: function (e) {
- e.item.select(!e.item.isSelected())
- }
- });
- });
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.
- $("#funnelContainer").dxFunnel("clearSelection");
See Also
User Interaction
When a user selects funnel items, they change their style to the one specified by the item.selectionStyle object.
- $(function() {
- $("#funnelContainer").dxFunnel({
- // ...
- item: {
- selectionStyle: {
- hatching: { direction: "left" }
- }
- }
- });
- });
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 UI component, assign it to the onSelectionChanged property when you configure the UI component. To check whether a funnel item was selected or the selection was cleared, call the item's isSelected() method.
- $(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
- }
- }
- });
- });
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.
- 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
If you have technical questions, please create a support ticket in the DevExpress Support Center.