How to use multiple renderers?
How to use multiple renderers?
richard.carree.com@gmail.com
Posts: 23Questions: 7Answers: 0
Link to test case: http://live.datatables.net/bufafegi/1/edit
Error messages shown: Uncaught TypeError: renderArray[r] is not a function
Description of problem: To use multiple renderers I followed this nice post. However my test case returns the aforementioned error.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
The primary issue is that you were using
$.fn.dataTable.render.colorNegative()
, but$.fn.dataTable.render.colorNegative
is in fact the renderer, so that should be passed in - not executed.But more than that, the
multi
renderer wasn't quite right - since renderers can contain objects, allowing different functions per type, with a_
property as fallback. Here is your test case updated to address both of them: http://live.datatables.net/bufafegi/3/edit .I'm wondering if we should include the multi renderer in DataTables core...
Allan
Sorry - my last change wasn't quite complete - here is the working version: http://live.datatables.net/bufafegi/4/edit .
Allan
Thanks Allan for this quality answer and working solution.
Since it allows to split big specific renderers to smaller and reusable ones, which is a good practice, I think it's a good idea. Also, it might be easier for the user to find the related doc as a reference instead of searching on the web to find this post.
If you're hesitating for core, may be plugins could be the right place for it.
Yes, I think short term it should probably go into the plug-ins, and then I'll think about it for v2 .
Thanks!
Allan
Committed in here.
Cool! Thanks Allan