How to write custom filter?

How to write custom filter?

mungomungo Posts: 4Questions: 0Answers: 0
edited April 2009 in General
Hello

I need to filter between range of currency?
I couldnt see much in the api for this, any recommendations on how to go about this?

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Hi mungo,

    Have a look at the demo here: http://datatables.net/1.5-beta/examples/api/range_filtering.html - the filtering plug-in isn't fully documented yet since it is only in the 1.5 beta series (quite stable even although it's beta :-) ), but it should be fairly trivial to modify to match your needs.

    Hope this helps,
    Allan
  • mungomungo Posts: 4Questions: 0Answers: 0
    rock on allan, thanks!
  • mungomungo Posts: 4Questions: 0Answers: 0
    Allan, you made me the happiest man on earth, 10 mins of implement datatables and i retained everything i was using from tablesorter + hacks and my custom filter works perfectly!

    Theres one issue Im having with the beta on the header sorting with currencies I have a $ infront of the numbers, and it seems to be upsetting the sorting
  • mungomungo Posts: 4Questions: 0Answers: 0
    edited April 2009
    selector:before{ content:"$"; }

    i used this in css, works great... who cares about ie 6 & 7 :D
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Hi mungo,

    Fantastic stuff - really good to hear that it isn't too arduous to make the switch! :-).

    With the currency sorting, DataTables will be sorting that information as a string (by default) since it doesn't have a built-in currency type. However, this is very easy to add using a plug-in: http://datatables.net/plug-ins . There are two plug-ins which will probably be of interest to you the currency sorting, and the currency auto-detection:

    http://datatables.net/plug-ins#sorting_currency
    http://datatables.net/plug-ins#type_currency

    The former with do the sorting that you are looking for, while the latter will automatically pick up the fact that a column should be sorted as a currency (if can be statically set using sType if you wish).

    Hope this does the trick for you!
    Allan
This discussion has been closed.