Skip to content

attachEvent

attaches the handler to an inner event of the component

function attachEvent(
// the event name, case-insensitive
type: string,
// the function object or name
functor: function,
// optional, the event id
id?: string
): void
dgrid.attachEvent("onAfterLoad",function(){
this.select(2);
});

also check the next samples:

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(){ ... };
dgrid.attachEvent("onBeforeLoad", doTask); // uses the reference

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).

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.

dgrid.attachEvent("onBeforeSelect", function(id){
if (id == 123)
return false; // blocks selection of a specific element
});

Articles

API