Custom html in TD's without messing with sorting?

Custom html in TD's without messing with sorting?

afflictoafflicto Posts: 2Questions: 0Answers: 0
edited February 2013 in General
Hi there. First of all I love this plugin!

I have a lot of 3 Weeks ago kind of stuff in my columns (td's).
This messes up sorting.

Any way to tell my datatable: "Hey, THIS is my custom content, HERE is the actual value."?

Thanks in advance!

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    You want it to sort on only the `3 Weeks ago` presumably? Or doe you want a proper temporal sort on the title attribute? For the former, that should just automatically work - if it doesn't please submit a test case showing the problem. For the latter, you need to use a plug-in that will read the title attribute and sort by date.

    Allan
  • afflictoafflicto Posts: 2Questions: 0Answers: 0
    HI there allan. Actually I'd like it to sort on the fully formatted datetime string. (Which works great)
    It would be nice to say .dataTable('valueGetter', 6, function() {return $(this).find('span').attr('title'))});
    Where I could register a function to run when datatable requests to get th value of column 6. or something :P
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hah - I'm going to working on some like along those lines today in fact :-).

    For the moment you could use the hidden title sorting plug-in (which basically does do that, but isn't a particularly slick solution): http://datatables.net/plug-ins/sorting#hidden_title

    Allan
This discussion has been closed.