fnFilter on Individual Columns

fnFilter on Individual Columns

Derek PerkinsDerek Perkins Posts: 2Questions: 0Answers: 0
edited May 2009 in General
I'm trying to filter on individual columns, but I am creating a custom form to filter on with select boxes, standard input boxes, checkboxes, etc. I know that there is the example that shows how to put input boxes into the footer, but I'm having trouble extending that to my form. This is the code that I have, but it isn't working. Is there something else I need to do to use a separate form to filter?
[code]
jQuery("select[@name=state]").keyup( function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter( this.value , 2 );
} );

jQuery("input[@name=stat]").keyup( function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter( this.value, 2 );
} );
[/code]

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Hi Derek,

    Which aspect of this isn't working? The only thing that I can see which is immediately odd about this is that you typically don't use 'keyup' for a SELECT element - you would use 'change'. Does it work as you would expect if you make this change?

    If not, perhaps you could explain a little more about what is actually happening (or not happning as the case might be) and if you have a link you could post, that would be more useful.

    Regards,
    Allan
  • alanomalyalanomaly Posts: 4Questions: 0Answers: 0
    (consider this a documentation comment for anyone scratching their head as to why a perfectly fine fnFilter call doesn't work and does nothing)

    One possible for fnFilter not working: If you've set { bFilter: false } in the tables settings in order to remove the default search box, doing so also disables all other filtering features, including fnFilter.

    A good way to turn off the default search box without disabling your own custom filters is to use sDom and don't include 'f'.

    For example, for a table with the default layout but no search box, without disabling fnFilter, you would use { sdom: 'lrtip' }
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Good tip - thanks for posting it :-)

    Allan
This discussion has been closed.