fnFilter + Regex

fnFilter + Regex

sstryckersstrycker Posts: 6Questions: 0Answers: 0
edited April 2013 in General
Hi I've seen other examples of using Regular expressions with fnFilter but I can't seem to get it working for myself. I need to filter a column that lists US States by the record ID which is a number... what's happening is that the results are being filtered by only the first part of the ID - for instance when I try and filter for the state "Arizona" which is ID = "3" it will also show "Oregon" in the results which has an ID of "36" - so it's only seeing "3" in Oregon and including it in results.

I'm guessing that fnFilter does a "LIKE" query instead of an "="?

here is my php code:

[code]

All States
<?php foreach ($state as $states): ?>
<?php echo $states['state']; ?>
<?php endforeach; ?>
?>

[/code]

Here's the javascript:

[code]
$('#state').bind('change', function() {
oTable.fnFilter( $(this).val(), 5 );
});
[/code]

I've looked through other posts and have tried to use Regex like this:

[code]
var state = "^"$(this).val();
oTable.fnFilter( state, 5, false );
[/code]

But this doesn't work at all...

Replies

  • sstryckersstrycker Posts: 6Questions: 0Answers: 0
    OK - sorry, I answered my own question! I just had to use the correct Regular expression :-\

    this works:

    [code]
    var state = "="+$(this).val();
    oTable.fnFilter( state, 5, false );
    [/code]
This discussion has been closed.