fnrowcallback search
fnrowcallback search
dan1dyoung
Posts: 2Questions: 0Answers: 0
Hi,
We use the fnrowcallback to translate the tables contents on the fly but the search (Filter) only works with the original untranslated data loaded from the JSON request. So if we send the JSON in English and then translate to Finnish we have to still search in english.
Can this be achieved, changing the search to look at the modified data??
We use the fnrowcallback to translate the tables contents on the fly but the search (Filter) only works with the original untranslated data loaded from the JSON request. So if we send the JSON in English and then translate to Finnish we have to still search in english.
Can this be achieved, changing the search to look at the modified data??
This discussion has been closed.
Replies
The end result would be that if you doing something like translating data, you might be translating the same string multiple times, which would just put unnecessary load on the processor.
What I would suggest you do is transform the JSON as it comes in. In DataTables 1.10 you can use `ajax.dataSrc` to do that ( http://next.datatables.net/reference/option/ajax.dataSrc ). In 1.9- you need to use fnServerData to write your own Ajax call with the transform in it.
This way the data is translated only once, and the translated data will be used for search, sort etc.
Does that make sense? Sounds like an interesting application! How are you doing the translation, is it a simple token lookup?
Allan
Using mRender instead of fnRowCallback works, but is there a downside to this and so a reason to use your way as above??
It is not me coding this but I will let you know the setup.
Thanks
Dan