DataTables logo DataTables

via Ad Packs
Custom Filtering with Exact Match
  • lorenzoatlorenzoat
    Posts: 3
    Dear all,

    I am trying to have a drop-down list in order to do custom column filtering.

    But, I can not obtaing an exact filter match. i.e. "1" is "1" no "11" or "21" or "1x" or "x1"

    You can check my tables in this url: http://www.rlmm.org/ojs-files/library.php

    Can you help how to modify my existing code?

    Regards,
  • 28.vivek.s28.vivek.s
    Posts: 69
    hi lorenzoat,

    you need to add extra regular expression in your string...try this...i am sure it will help you.. don't forget to disable regx in filter function.
    valueNeedtoFilter = "^\\s*"+data+"\\s*$";
    oTable.fnFilter(valueNeedtoFilter ,iColumn,false,);
    
    You can see this post also...http://datatables.net/forums/comments.php?DiscussionID=4096&page=1#Item_5
    Thanks,
    Vivek
  • the correct format and values for exact match are

    sortby = "^\\s*"+data+"\\s*$";
    oTable.fnFilter(sortby, iColumn, true);
    
  • rajeshArajeshA
    Posts: 4
    exact match is not working
    This is my code
    $("#fromDate").change( function () {
    var oSettings = oTable.fnSettings();
    oSettings.aoPreSearchCols[ 3 ].bRegex = false;
    oSettings.aoPreSearchCols[ 3 ].bSmart= false;
    var valueNeedtoFilter = "^\\s*"+this.value+"\\s*$";
    oTable.fnFilter( valueNeedtoFilter, $(".filters th input").index(this),true);
    } );
    Any one help me
  • allanallan
    Posts: 15,556
    Drop the white space matching - it shouldn't be needed with individual column filtering.

    Allan
  • rajeshArajeshA
    Posts: 4
    i didn't understand, can you explain little bit more, it will helpful for me
  • allanallan
    Posts: 15,556
    You've got white space matching in your variable valueNeedtoFilter that you use to filter the column. I would suggest (unless you specifically put white space in the data for the columns) that you need to remove that.

    Allan
  • rajeshArajeshA
    Posts: 4
    Thanks for your reply.

    I have the following values in table
    Jul 15, 2012
    Jul 5, 2012
    Using Date calendar am display Jul 5, 2012. It's displaying two values. am used the above posted code only.
  • rajeshArajeshA
    Posts: 4
    Am changed lot of way, but still unable to get exact matching result. Any one help me to fix this issue
This discussion has been closed.
← All Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.

In this Discussion