fnFilter regex multiple columns (v1.5.0)

fnFilter regex multiple columns (v1.5.0)

tlisantitlisanti Posts: 1Questions: 0Answers: 0
edited August 2009 in General
Hi,

I'm wanting to use a regex filter on two columns. For instance, in the example below, the two columns that I'm wanting to filter on are "Home Teams" and "Away Teams". I'm wanting to use a regex because I don't want the second row (UNC vs Florida State) to display when a user filters on NC State. I'm wanting to filter on two columns because I want the first and third rows to display if a user filters on NC State. NC State displays in the "Away Team" column for the first row and "NC State" display in the "Home Team" column of the third row. The example below works for only one column. Hopefully somebody can help.

[code]
<!--

$(document).ready(function() {
oTable = $('#dt_vertical').dataTable();
$("select#show_team").change(function () {
var val = $("select#show_team option:selected").attr('value');
var regex = (val == "" ? "": "^"+val+"$");
oTable.fnFilter (regex,3,false);
});
} );

// -->

<!--
.dataTables_filter { display:none; }
.dataTables_length { margin:-22px 0 3px 15px; }
-->

| Team Selection:

Show all
Clemson
NC State





Date
Time (p.m. ET)
Away Team
Home Team
TV




September, 3 2009
7:00
South Carolina
NC State
ESPN


September, 10 2009
1:00
UNC
Florida State
ESPN360.com


September, 19 2009
7:00
NC State
Clemson
ESPN



[/code]

Replies

  • allanallan Posts: 54,909Questions: 1Answers: 8,606 Site admin
    Hi tlisanti,

    What I think you will need to do to get what you are looking for is customise the filtering that DataTables performs by using a custom global filtering function. Information on how to do this can be seen here: http://datatables.net/development/filtering

    Regards,
    Allan
This discussion has been closed.