1:1 Filtering - select combo box' value == DataTable field value?

1:1 Filtering - select combo box' value == DataTable field value?

douglasdouglas Posts: 5Questions: 0Answers: 0
edited June 2010 in General
Hello everyone,

my DataTable contains a column with the words "active" and "inactive". I got a select combo box with both of these values for filtering the content.

It's showing rows with "inactive" when "active" is selected, because - logically - it's in the word.
[code]
$('#status').change(function() {
var choice = $('#status').val();
oTable.fnFilter( choice, 3 );
});
[/code]

Is there any way I can say the text has to be identical 1:1?

Thanks in advance.

Douglas

Replies

  • PetrPetr Posts: 7Questions: 0Answers: 0
    Hello,
    It looks like you must create your own filter. Try look at this sample
    http://datatables.net/1.5-beta/examples/api/range_filtering.html
  • douglasdouglas Posts: 5Questions: 0Answers: 0
    edited June 2010
    Hello again,

    I tried to do this, but it doesn't seem to work:

    [code]$('#status').change( function( oSettings, aData, iDataIndex ) {
    var choice= $('#status').val();
    if ( aData[3] == choice)
    {
    return true;
    }
    return false;
    });[/code]
  • captainmoecaptainmoe Posts: 2Questions: 0Answers: 0
    I just had this problem actually, hopefully you solved it. If not hopefully this helps somebody else. I had to use regex to make sure Active was only matching Active.

    [code]
    oTable.fnFilter( '^Active' , 3 , true )
    oTable.fnFilter( '^Inactive' , 3 , true )
    [/code]

    Are the two methods I used.
This discussion has been closed.