{hero}

user-select

Since: Select 1.2.0

A user action will cause items to be selected in the table.
Please note - this property requires the Select extension for DataTables.

Description

This event is triggered before items are selected based on an interaction with the table by the end user (typically clicking on a cell in the table).

This event is cancellable - i.e. using e.preventDefault() or return false; in the event handler will stop Select from performing any further actions for the selection. This can be useful for cases where you don't want certain items in the table to cause item selection (for example you might have images which perform some other action and should not activate row selection).

Note that this event will not be triggered when the API methods for item selection are used (e.g. row().select()). It will only be triggered by an end user action defined by select.selector.

Additionally, as with all DataTables emitted events, this event is triggered with the dt namespace. As such, to listen for this event, you must also use the dt namespace by simply appending .dt to your event name (this is done automatically when using on() and one()).

Type

function function( e, dt, type, cell, originalEvent )

Parameters:

Example

Prevent item selection when clicking on an image:

var table = new DataTable('#myTable', {
	select: true
});

table.on('user-select', function (e, dt, type, cell, originalEvent) {
	if (originalEvent.target.nodeName.toLowerCase() === 'img') {
		e.preventDefault();
	}
});