Handling Events

Common use

DHTMLX Connector uses events to manage Insert/Update/Delete operations.

The code below shows how to attach an event:

$conn->event->attach(event_name,handlerFunc);

Parameters:

  • event_name - a name of the event.
  • handlerFunc - a handler function.

Handler functions get one input parameter and this parameter depends on the attached event.

In the following table you'll see a full list of events and the appropriate input parameters of handler functions.

Event Input parameter of handler function
beforeSort SortInterface Object
beforeFilter FilterInterface Object
beforeRender DataItem Object

DataAction Object
beforeOutput none

Data behavior models

Starting from version 1.5, the library 'extends' OOP support and allows creating a separate class for events processing. You get the possibility to work with one class that will control all processing instead of working with separate handler functions.

class SomeBehavior{
    public function beforeRender($data){
        //some logic
    }
    ... any other handlers ...
}
$conn->event->attach(new SomeBehavior());

The handlers of the model class take the same parameters as the ordinary events do

Back to top