fnMultiFilter: exact string matching and sClass vs. sName

fnMultiFilter: exact string matching and sClass vs. sName

dylanmacdylanmac Posts: 49Questions: 7Answers: 1
edited February 2014 in Plug-ins
I've installed the fnMultiFilter and am calling it to search two different columns in my table with two values. I have two questions:

1. I modified the plugin to use sClass instead of sName. I assume it doesn't matter?

[line 8] if( oSettings.aoColumns[i].sClass == key )


2. I am passing in two query parameters to the function. It appears that fnMultiFilter is using partial match rather than exact match. I say that because "Class A" is finding all rows which I assume is because "A" is in "Class". Same for "Class C". "Class B" only finds rows with "Class B" in the column which would fit my assumption.

Is it because I have a space in my value? How do I force it to use exact match?

oTable.fnMultiFilter( { "col21": "Class A", "col30": "2" } );

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited February 2014
    > 1. I modified the plugin to use sClass instead of sName. I assume it doesn't matter?

    Not as far as I am aware :-). The code is there to be modified!

    > Is it because I have a space in my value? How do I force it to use exact match?

    Yes - DataTables is doing a "smart" filter which breaks the words up and matches them in any order. You want to disable that for the column.

    [code]
    oSettings.aoPreSearchCols[ i ].bSmart = false;
    [/code]

    One thing worth noting here is that DataTables 1.10's new API provides the ability to built a complex filter using the public API's, with where multiple filters can be added before calling the `draw()` method. It isn't quite as succinct as fnMultiFilter, but it is a public API: http://next.datatables.net/reference/api/column().search() unlike how fnMultiFilter works.

    Allan
  • dylanmacdylanmac Posts: 49Questions: 7Answers: 1
    Allan -

    Thanks for your reply. I cannot get the fnMultiFilter working. It brings back null results (even when I search against one column) despite the fact that breakpoints in the plugin reveal it is stepping through the functions. So I'm trying out DT 1.10 beta. It looks great but I am not sure how to construct a multi-column filter with smart filtering turned off. Is it like so?

    $('#table').DataTable().columns( col1Index,col2Index ).search( filterValue1 [[false]], filterValue2 [[false]] ).draw();
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    I've just replied in your other post asking this exact question: http://datatables.net/forums/discussion/19491/

    Allan
This discussion has been closed.