What are the types used by 'render' used for?
What are the types used by 'render' used for?
In the columns.render documentation the render function template is 'render(data,type,row,meta)'
From the documentation:
The type call data requested - this will be 'filter', 'display', 'type' or 'sort'.
I suggest a slight rewording of this:
The type or format for data requested - this will be 'filter', 'display', 'type' or 'sort'..
display: used as the table cell displayed information
filter: used when doing a search operation (see: colums.search)
type: magic... ????
sort: used when sorting (see: ????)
This issue came up when I was doing sorting of a column which had mixed numeric and text information.
When sorted, 94 came after 904, when it should have been 94 and then 904. I tried to fix this issued by
using render and for numerical values padded them out to 00094 and 00904. Now they sorted correctly.
I think a bit more details about the sort support in the documentation would be useful. Does 'type' and 'sort'
interact?
This question has accepted answers - jump to:
Answers
Dig further into the documentation
https://datatables.net/manual/data/orthogonal-data
https://datatables.net/reference/option/columns.type
Improving the documentation there sounds eminently sensible - thanks for flagging this up. I've committed the change and will deploy it to the site soon (probably alongside the 1.10.13 update).
Regards,
Allan
Thanks!
It took me a while to realise that this was causing my data not to sort. I'm using a function to return the date for each cell, and of course the function must also return the sort and filter values which made sense. Unfortunately my code was dropping through to return a default value of zero. When a changed it to return 'string' for the type it worked.
Great product. Keep up the good work.