sorting -pre -asc and -desc
sorting -pre -asc and -desc
xtech_dev
Posts: 25Questions: 11Answers: 0
I'm developing custom ordering plugin based on: https://datatables.net/manual/plug-ins/sorting
What is the meaning of -pre function? Does it prepare data for -asc and -desc functions or -asc and -desc does not matter when -pre is defined?
This discussion has been closed.
Answers
Ok, got it.
-pre wont work with -asc, -desc (it's a pity).
From docs:
"Note that in DataTables 1.10 a pre-formatter cannot be used with custom -asc and -desc methods - to use custom ordering functions you cannot apply a pre-formatter. This limitation will be addressed in the next major version of DataTables."
Hi @xtech_dev ,
I think that comment is out of date - it does work with them, see a one of my plugins here.
In that example, the "-pre" formats the data into something that's easily comparable by the "-asc" and "-desc" functions. If there isn't a "-pre" function, the "-asc" and "-desc" will just use the raw data for that cell.
Hope that helps,
Cheers,
Colin
Well it seems that -pre function does not takes in to account the .render function. I have done some preprocessing in my render function for non 'display' type. But when -pre is running not calls for render are made.
I built a simple example based on the example in the doc you linked to. The -pre function seems to work:
http://live.datatables.net/sefonamu/1/edit
Please provide an example of what you are trying so we can help debug.
Kevin