Using selector for targets
Using selector for targets
Lapointe
Posts: 430Questions: 81Answers: 4
Hi
We can use
columns: [':gt(0)']
to select columns... Why not usable for targets ?
targets:['gt(0)']
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I guess you are asking about the
columnDefs.targets
option. The docs state it supports the following:Using
:gt(0)
is a jQuery selector which is not an option thatcolumnDefs.targets
supports.Kevin
Hi Kevin
I agree and already had a look to targets selector possibility.
In fact it should be interresting to allow this kind of selector, because not need to count the column to disable all else the 2 first for example...
So question is in feature request...
You could use a jQuery statement to add a classname to all but the first 2 columns then use that classname as the
columnDefs.targets
. For example:http://live.datatables.net/yumifozu/1/edit
Sorry, didn't notice that :-)
Kevin
The issue with using a DOM selector for
columns.targets
is that the columns having been processed by DataTables at that point (i.e. they might not even exist if you are usingcolumns.title
to create the column). They also having had any classes assigned bycolumns.className
.I took the decision of going with the lowest common denominator. Instead of allowing the targets to use DOM queries, which would only work in some cases, I thought it might save confusion. I might have been wrong to take that approach .
An option that would work just now, if you have DOM defined columns, would be to use jQuery to select those columns and then use a
map
combined withindex()
to get an array of the column indexes, which can be assigned tocolumns.targets
.Allan
Hi Kevin, @allan
No matter... It was just a question.
Datatables is an amazing dev, and I'm just (each day) learning JS ans JQ to be a better software coder...
In fact I'm a little (little ?) bit lazy and have to count from 1 to x many time in dev mode...
Thanks again all