attachEvent

attaches the handler to an inner event of the component

id attachEvent(string type,function functor, [string id] );
typestringthe event name, case-insensitive
functorfunctionthe function object or name
idstringoptional, the event id
idthe id of the attached event handler

Example

dtable.attachEvent("onAfterLoad",function(){
    this.select(2);
});

Related samples

Details

How the handler is provided

You can use the method with an inline function or provide just the global function reference. In the second case, be sure that the function is visible from the calling point.

function doTask(){ ... };
dtable.attachEvent("onBeforeLoad", doTask); // uses the reference

The handler id

The last parameter allows you to define the id of the attached handler. If it was not specified, some unique value will be assigned as the id. The only purpose of such id - detaching the handler from an event (in most cases you don't need to care about the handler id).

Handler function parameters

Check the related documentation to get the full list of parameters. The amount and meaning will vary for different events.

The value which is returned by an event can change behavior of component. Returning true or nothing will be considered as the positive signal, while returning false will be considered as a signal to stop the current activity.

dtable.attachEvent("onBeforeSelect", function(id){
    if (id == 123)
        return false; // blocks selection of a specific element
});
See also
Back to top
If you have not checked yet, be sure to visit site of our main product Webix js frameworks and page of datagrid javascript product.