custom sort function not working with mRender

custom sort function not working with mRender

ssloanssloan Posts: 4Questions: 0Answers: 0
edited June 2013 in General
Hi there,

I'm using a custom afnSortData function to provide sorting values for a column in my table. The column contains numeric data, but also a colour-coding span to indicate information to the user, so I need to strip this out for the numeric sorting to work properly.

If I do this with static content in the cells, it works, you can see it here: http://jsfiddle.net/G2MPR/1/

However, when I instead populate the table with data using fnAddData to get the data out of a javascript array, it doesn't work. My custom function runs and returns the same (correct) data to sort on as before, but the sorting doesn't actually happen. You can see this behaviour here: http://jsfiddle.net/cHtNs/5/

Can anyone tell me what the problem is when I'm populating the data from an array please?

Thanks,
Sarah

Replies

  • ssloanssloan Posts: 4Questions: 0Answers: 0
    I've done some more digging on this and it seems that the _aSortData is not updated for the values returned from my afnSortData function when using fnAddData, but it when using static html content. It seems _aSortData is being populated before my aoColumnDefs are loaded so dataTables doesn't know to call my function when doing the initial sort. I've tried not using an initial sort but that hasn't helped.
This discussion has been closed.