Select plugin - selection on all columns, except the first one
Select plugin - selection on all columns, except the first one
I would like to ask you for advice and to get know.
What is the proper selector, if I am using the selection in the Select plugin to work on all columns, except the first one?
I have tried to use different combinations and I could not find the right one.
By the way, I would like to point out that you probably have an error in your documentation:
https://datatables.net/reference/option/select.selector
Allow selection on all but the last column:
$('#example').DataTable( {
select: {
style: 'os',
selector: ':not(:last-child)'
}
} );
Example: https://jsfiddle.net/rq320vfb/1/
This selector does not select the last row in the table correctly.
This question has accepted answers - jump to:
Answers
Instead of
selector: ':not(:last-child)'
the selector should beselector: 'td:not(:last-child)'
.@allan will need to fix the docs.
The same if you want to enable select on all but the first column:
selector: 'td:not(:first-child)'
.Kevin
Hi Marek!
I am surprised your code above works without the "td" in it. Maybe you want to try it with "td" and also the last row will be selected properly?! Because in your example the last row can be selected ONLY on the last column while all other rows can be selected ONLY on all columns EXCEPT for the last column. That leads me to the assumption that the selector isn't specific enough. ':not(:last-child)' seems to be interpreted as a "td" element in all rows but the last and as a "tr" element in the last row.
So you might also want to try this:
That should exclude all columns but the first one. And it should completely exclude the last row, I guess. Or it will exclude the last row except for its first column. Well, you'll figure it out!
Roland
Thanks for your help. I did not mean that the last line to be excluded. Anyway, based on the advice, I wrote the correct selector:
selector: 'tr td:not(:first-child)'
Unfortunately, the error in documentation, misled me. I hope Allan will make a correction soon. Thanks again.