Orthogonal data: Just use the 'data' property
Orthogonal data: Just use the 'data' property
if I have a columns
object defined like this:
{
data: 'height',
type: 'num-fmt'
}
And then I add a columnDefs object for it like this:
{
targets: [14],
render: {
display: function(d) { return 'Approx. ' + d + ' meters'; },
sort: height,
}
}
I'll get an error for the sort
property, because DT will try to look for height.height (or height[i].height?). DT expects several differently-formatted values under the same property in the data, but that isn't always the case. Is there a way to tell it to just use same data as the columns
definition -> data
property?
Or is this the only way:
sort: function(d) {
return +d;
}
This question has an accepted answers - jump to answer
Answers
It depends upon what is in the variable
height
.Set the
_
property of therender
object to null. Then the data will be used unless there is an override given.Allan
Cool, I thought there might be something like that in there but I couldn't find it in the docs. (I didn't really know what to search for).
Thanks again, Allan!