Exact column matching problem

Exact column matching problem

danstauntondanstaunton Posts: 6Questions: 0Answers: 0
edited January 2014 in DataTables 1.9
Hi,

I am trying to filter my results by values in column 0. For your information column 0 holds a unique call reference number in my table.

$(document).ready(function() {
oTable = $('.dataTable').dataTable();
oTable.fnFilter(100, 0, true, false, false);
} );

The above should only display results with a reference number of 100. However it displays results like 100, eg "100" , "10000" "1000001"

I have also tried

oTable.fnFilter("^"+100+"$", 0, true, false, false);

however this returns "No matching records found"

Thanks in advance for your help.

Dan

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Hi Dan,

    As you have indicated regular expression matching is required for an exact match. This example shows it working: http://live.datatables.net/IMOz/1/ .

    Can you please link to a test case showing the error (as noted in the forum rules).

    Allan
  • danstauntondanstaunton Posts: 6Questions: 0Answers: 0
    edited January 2014
    Hi Allan,

    Apologies for not the posting a test case.
    Thanks for posting your example however I still cannot see where I am going wrong.

    Here is my test example. It should be filtering column 0 which has a value of 2.

    http://79.174.222.26:8080/dashboard/portal.php
  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    > server-side processing

    Ah. That's the information I was missing.

    In that case its up to your `calldetails.php` script, whatever is in there, to do the filtering. You will probably want to not use a regular expression (for performance) but instead manipulate the WHERE condition to do exact matching (assuming that at the moment it is not).

    Allan
  • danstauntondanstaunton Posts: 6Questions: 0Answers: 0
    Thanks Allan,

    I changed the where clause for individual column filtering

    [code]$sWhere .= $aColumns[$i]." like '%".mysql_real_escape_string($_GET['sSearch_'.$i])."%' "; [/code]
    to
    [code]$sWhere .= $aColumns[$i]." = '".mysql_real_escape_string($_GET['sSearch_'.$i])."' "; [/code]
This discussion has been closed.