Skip to content

onClick

attaches a click handler for component parts with the specified CSS class

let onClick: EventHash
webix.grid({
columns:[
{ id:"rank", header:"", css:"rank", width:50},
{ id:"title", header:"Film title", width:200},
{ template:"<input class='delbtn' type='button' value='Delete'>", width:100 }],
on:{
// the default click behavior that is true for any datagrid cell
"onItemClick":function(id, e, trg){
console.log("Click on row: " + id.row+", column: " + id.column)
}
},
// a click behavior for the cell with a button styled with 'delbtn' class
onClick:{
"delbtn":function(e, id, trg){
console.log("Delete row: "+id);
return false; // here it blocks the default behavior
}
},
data:grid_data
});

also check the next samples:

  • the “onClick” behavior is defined for the component items rather than for the whole component

  • use the “onItemClick” handler to attach a function to item clicking regardless of the CSS class;

  • the onClick handler can override the default onclick event:

  • pay attention to returning false from the onClick handler in the above example. It blocks all further click-related events: onBeforeSelect, onAfterSelect, onSelectChange, onItemClick.

Articles

API