bDeferRender and FixedHeader cause sorting class issues

bDeferRender and FixedHeader cause sorting class issues

agarbelmanagarbelman Posts: 1Questions: 0Answers: 0
edited December 2012 in FixedHeader
Minor bug:
When using the feature "bDeferRender" on a DataTable, the fnSortingClasses function gets pushed to the aoDrawCallback array during initialisation to add the sorting classes onto the header elements after every draw. Then during the FixedHeader plug-in initialisation, the FixedHeader updating methods are also pushed to the aoDrawCallback array to be called after every draw. Unfortunately, because these callback arrays are called in reverse order, this means that the FixedHeader will be updated before the fnSortingClasses function is called to put the right sorting classes in place. This leaves the sorting classes on the FixedHeader one draw event behind.

This can (hopefully) be seen on the jsfiddle I put together here: http://jsfiddle.net/pAZjr/10/
And is most obviously seen by clicking on one of the column headers to sort the list - noticing that the list does get sorted in ascending order properly, but the header's sort classes (and therefore icons) are unchanged until you redraw.

I fixed this in a rather hackish way by changing the aoDrawCallback.push to an aoDrawCallback.unshift when adding the FixedHeader's updating functions to the aoDrawCallback array, so that they are performed after any other draw callbacks. I have not seen this cause any additional problems with my usage, but have not tested/evaluated it fully.
This fix can be seen here: http://jsfiddle.net/pAZjr/11/

If anyone has alternative methods to fix this problem I'd love to hear them.
Thanks
This discussion has been closed.