简体   繁体   中英

How to remove default click event from a column of datatable?

I have brought datatable's default click event on every first column by disabling responsive display's type //type: 'none', . Now, for some targeted action, I want to disable those click event from the first columns.

So, I have written this:

$('td:first-child').off('click');

But, click event hasn't been stopped. How to do this? Here is my demo .

This plugin does not seem to attach individual click handlers. Rather there is a global handler on tbody and all the logic is within. So the whole thing becomes a double-edged sword. You can achieve what you want using this:

$('tbody').off('click.dtr mousedown.dtr mouseup.dtr');

However, you should keep in mind a few things:

  1. There might be some undesired side-effect to this. I do not know how exactly this large handler works so in order to figure this out you should check the code out (which is where I found the correct events and their namespaces): download the non-minified code with the Response extension, find the _detailsInit() function and read through it - that should be a good enough start .
  2. There are probably some keyboard handlers as well, and depending on what you are doing you might want to take care of those too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM