just replace
$(document).ready(function () { $('#example').DataTable({ "responsive": true, "dom": '<"top"lf>t<"bottom"pi><"clear">' }); });
by
$(document).ready(function () { $('#example').DataTable({ "responsive": true, "dom": '<"top"lf>t<"bottom"pi><"clear">' }); $('td').on('click mousedown mouseup', function(e) { if (e.target.type === 'checkbox') { e.stopPropagation(); } }); });
this part will stop the spread of the click if you click on the checkbox
$('td').on('click mousedown mouseup', function(e) { if (e.target.type === 'checkbox') { e.stopPropagation(); } });
plunker: http://plnkr.co/edit/PCHdDM7UGD0BLXoDhhD6?p=preview
EDIT:
To remove the functional functionality of the cell and add it only to minimize / expand the button, I had to create a new html element and put it in the cell: '<div class="clickBtn">+</div>'
Why? Because the old button was in front of the pseudo element: therefore, it was not actually in dom. I need an element in dom to allow wasting / crashing when I click on that particular element, not the whole cell.
Then I give this button the css of the old button
.clickBtn { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; cursor: pointer; top: 9px; left: 4px; height: 14px; width: 14px; position: absolute; color: white; border: 2px solid white; border-radius: 14px; box-shadow: 0 0 3px #444; box-sizing: content-box; text-align: center; font-family: 'Courier New', Courier, monospace; line-height: 14px; background-color: #337ab7; }
and delete the old one:
table.dataTable.dtr-inline.collapsed>tbody>tr>td:first-child:before, table.dataTable.dtr-inline.collapsed>tbody>tr>th:first-child:before { display: none; }
Now I need to change the behavior of clicks on the cell only if you click the minimize / expend button.
$('td').on('click mousedown mouseup', function(e) { if (e.target.className === 'clickBtn showBtn') { if (e.target.innerText === '+') { e.target.innerText = '-'; e.target.style.backgroundColor = 'red'; } else { e.target.innerText = '+'; e.target.style.backgroundColor = '#337ab7'; } } else { e.stopPropagation(); } });
When you click on a cell, if the target of your click is not an element with the class "clickBtn" and "showBtn", it stops the event from propagating. This is why only clickBtn can spend / collapse now.
this part simply recreates the old button color and text:
if (e.target.innerText === '+') { e.target.innerText = '-'; e.target.style.backgroundColor = 'red'; } else { e.target.innerText = '+'; e.target.style.backgroundColor = '#337ab7'; }
EDIT 2:
To remove the blue part, which is the text selection, I had to add this css to the button:
-webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;