fnFilter("<=2", 8); is not working

fnFilter("<=2", 8); is not working

rasmuslindstromrasmuslindstrom Posts: 7Questions: 0Answers: 0
edited December 2012 in General
I have been searching for this, I want to show all values that are 2 or less.

I want this to work, but it's not working: oTable.fnFilter("<=2", 8);

How can this be done via fnFilter?


Big thanks in advance!

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    No - the build in filtering is string based, so it is search for the literal text `<=2` .

    To do range filtering you need to use a custom filter: http://datatables.net/development/filtering#row_filters

    Allan
  • rasmuslindstromrasmuslindstrom Posts: 7Questions: 0Answers: 0
    Thanks Allan, I almost got it to work. Thanks for your input so far.

    I have 4 radio buttons with a .click(); to each one of them. I made two inputs with the IDs directMin and directMax

    When clicking on the "0 to 0" radio button, the input fields gets the correct numbers, but the table doesn't change. If I then click on the "0 to 1" radio button, the input fields change and the table changes to "0 to 0", I tried with more radios and more ranges and the filtering function is one step behind all the time.

    This is how I do within the click()
    [code]$( "#directMin" ).val(0);
    $( "#directMax" ).val(1);
    $('#example').dataTable().fnDraw();[/code]

    But it behaves like the draw is before the values are being changes.

    Do you have any ideas why it behaves like this?
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    That looks like it should work to me assuming the filter is reading #directMin/Max dynamically? But I can't say without seeing a test case. Please do link to one:

    http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
This discussion has been closed.