iimanii - Support for custom sort plugins is being removed? Or is it just a bug
iimanii - Support for custom sort plugins is being removed? Or is it just a bug
So basically I have these non-linear sorting functions which tends to push down the "null" values either in asc or desc, I'm also doing some formatting before sorting ( "pre" sort function ).
As of ver 1.10, the custom sorting functions will not get called if there is a "pre" function defined. (check line 4400)
I've also found the comment "4427: // Depreciated - remove in 1.11 (providing a plug-in option)"
So whats that all about ?
Note from Allan - Apologies, I deleted your discussion by mistake as I had it open in two tabs and thought it was a duplicate... doh.
Replies
Its an optimisation. If there is a
pre
function, then the external sort functions don't need to be called since thepre
function should be formatting the data into a sortable format using the JavascriptArray.sort()
method.If you need
sac
anddesc
functions, don't provide apre
function.I'm actually not sure that I will remove the asc and desc support in 1.11, but it isn't needed in 99.9% of cases which is why I've marked it for removal at the moment...
Allan
well basically, it seems that the
pre
values are cached, which would make the running time faster than just embedding the code insideasc
anddesc
and redoing the work every timeTrue the
asc
anddesc
would be the same in most of the cases, but in the case I've mentioned above I have to define those functions.In the mean time I had to alter the datatable source code to be able to use the functionality.
anyways I hope you keep it. I also hope you can consider the following as a replacement for code starting @ line 4400 within _fnSort
Rather then using
pre
and modifying the source, wouldn't you just do something like the natural sorting plug-in does and simply call a formatting function: http://datatables.net/plug-ins/sorting/natural . You trade memory for processor time, but it will work without modifying the source.Allan
It seems that using "mRender" would solve the issue in a more efficient way, If I pre-compute the sort values