How do you use fnSortListener?

How do you use fnSortListener?

chobo2chobo2 Posts: 23Questions: 2Answers: 0
edited June 2010 in General
Hi

I am wondering if fnSortListener is what I need but I don't understand how it works(from the example). This is my problem. I have a column that has dates like this

Aug 13 @ 4:04 PM

This date would be very hard to make a sorter for especially since no year is shown(it is not really useful to the user).

So what I want to do is have a hidden column with a date stamp something that datatables already knows how to sort by.

So when a user clicks on the column with these Aug 13 @ 4:04 PM dates in it. It actually sorts the hidden column.

Can fnSortListener do this? All my other columns should be fine and sort so they don't need hidden fields.

Replies

  • sielsiel Posts: 5Questions: 0Answers: 0
    sounds good,but I don't know how to help you:(
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    I would recommend using iDataSort rather than fnSortListener for this: http://datatables.net/usage/columns#iDataSort . It's probably possible to do what you want with fnSortListener, but a lot more complicated that using the built-in method for doing what you are looking for :-)

    iDataSort will tell DataTables to sort by a different column for the column that is the 'target'.

    An alternative, if you didn't want to use a hidden column, would be to use the hidden title numeric sorting plug-in: http://datatables.net/plug-ins/sorting#hidden_title . This will take a number from a span tag's title attribute and sort on that.

    Regards,
    Allan
This discussion has been closed.