Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable ctrl+click selection in jQuery dataTables

I am using the jQuery DataTables plugin: http://datatables.net/examples/basic_init/zero_configuration.html

By default users are able to select cells by holding the control key and clicking.

I would like to disable this functionality. There does not seem to be an option or api function for this.

Does anyone know how I can achieve this, preferably without modifying the original source?

Thanks!

like image 750
SaphuA Avatar asked Nov 27 '25 05:11

SaphuA


1 Answers

This is not a dataTables issue - it is a browser issue. There is nothing in jQuery dataTables that provides this "feature". And to be more clear : It is a FireFox specific feature that do not exists in Chrome or Opera (for example).

Try open a FireFox, go to this page and ctrlclick on your own question above. Yes - the exact same thing happens!

If you programmatically want to disable this feature, see https://support.mozilla.org/en-US/questions/763547.

Very simple, add -moz-user-select: none to elements you not want to be selected by ctrlclick in FireFox. Here is an example :

table.dataTable tbody th, table.dataTable tbody td {
    -moz-user-select: none;
}

demo -> http://jsfiddle.net/0o0h2ry7/

...disables the ctrlclick feature in FireFox for a dataTable (1.10.x)

like image 143
davidkonrad Avatar answered Nov 28 '25 20:11

davidkonrad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!