Exact search match in 1.10

Exact search match in 1.10

lyndonwillyndonwil Posts: 40Questions: 5Answers: 0
edited April 2014 in DataTables 1.10
I'm trying to search on a numerical column and i'd like to display and ID value of 1 rather than 21,31,41 etc...

I thought this may do the trick but it doesn't fire any records back ?

[code]
$('')
.prependTo( $(columnTh))
.on( 'change keyup', function () {
table.column( indexColumn )
.search( "^"+this.value+"$", true, false)
.draw();
})
[/code]

I'm guessing i've missed something very simple !

Lynd

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    That looks like it should work to me. Here is a little test case checking it: http://live.datatables.net/zahegix/1/edit .

    Can you link me to a test case which doesn't please?

    Allan
  • lyndonwillyndonwil Posts: 40Questions: 5Answers: 0
    Hi Allan,

    Sorry for the delay.. Here's a test case

    http://cloud-contractor.co.uk/zTest2.php

    Also, if you look at the link below, it uses a non exact search and works fine

    http://cloud-contractor.co.uk/zTest1.php


    Thanks

    Lyndon
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited April 2014
    > "serverSide": true,

    The filtering is being done at the server-side, so its not really a DataTables error.

    Does your `tablepdo.php` script accept regular expressions? I suspect probably not, given the error. That script would need to be updated to provide exact matching abilities (easiest way is just to remove the `LIKE %%` stuff probably, although I don't know what is in that script).

    Allan
  • lyndonwillyndonwil Posts: 40Questions: 5Answers: 0
    Allan

    Thanks for the scarily fast reply ;-)

    i think my brain has stopped working. you're absolutely right..

    the tablepdo.php is basically your server_processing.php

    and i'd need to change the filtering within the equivalent of ssp.class.php ?

    Lynd
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yup - have a look at where the filtering is done and you'll use that a wildcard filter is used. You could just remove that and it would do exact matching.

    Allan
  • lyndonwillyndonwil Posts: 40Questions: 5Answers: 0
    thanks Allan

    just to be very awkward.. would you recommend any approach for having exact matching on one column and then normal matching on the others ?

    Lynd
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yeah - you'll need to do a conditional match on that column. `if ( $i === 0 )` for example.

    Allan
  • lyndonwillyndonwil Posts: 40Questions: 5Answers: 0

    Thanks Allan,

    I didn't explain my question very well.. What i wanted to do was send data from the table which i could intercept in the script and then conditional match accordingly..

    I've got it working now using ajax data, fantastic.

    "data": function ( d ) {
           d.exactSearchCols = [0,11,12]
    }
    

    Thanks again

This discussion has been closed.