Event Handling

Attaching event listeners

The user can add any user-defined handler to any of the available events. To do this, the user can use the dataview.events.on() method with the following parameters:

  • evName - name of the event;
  • evHandler - user-defined event handler.
dataview.events.on("Click", function(id){
   console.log("The item with the id "+ dataview.selection.getId(id) +" was clicked.");
});

Several handlers can be attached to one and the same event, and all of them will be executed.

The names of the events are case-insensitive.

Detaching event listeners

There is a simple way of removing an event handler via the dataview.events.detach() method:

var onclick = dataview.events.on("Click", function(id){
   console.log("The item with the id "+ dataview.selection.getId(id) +" was clicked.");
});
 
dataview.events.detach(onclick);

Calling events

To call events, use dataview.events.fire():

dataview.events.fire("name",args);
// where args is an array of arguments

List of supported events

You can find the full list of Dataview events in the API Reference.

Back to top