multiple fnFilter question

multiple fnFilter question

BoZoBoZo Posts: 6Questions: 0Answers: 0
edited September 2011 in General
Hello,

i have got a oTable with multiple fnFilter options for every column via API.
But for every fnFilter i have to send a new Request.

[code]
$('#example').dataTable().fnFilter(
$("#txt1").val(),
2,
true
);

$('#example').dataTable().fnFilter(
$("#txt2").val(),
3,
true
);

$('#example').dataTable().fnFilter(
$("#txt3").val(),
5,
true
);

[/code]

Can I combine these Requests to one Request?

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    allan's hint in this post (http://www.datatables.net/forums/discussion/997/fnfilter-how-to-reset-all-filters-without-multiple-requests./p1) might give you a clue

    maybe you can change oSettings.aoPreSearchCols[ iColumn ].sSearch for all 3 columns before triggering the fnDraw()
  • BoZoBoZo Posts: 6Questions: 0Answers: 0
    hm.. how can i give oSettings that the search is regexp = true?
  • BoZoBoZo Posts: 6Questions: 0Answers: 0
    ok I have it. Thank you :)
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    please post your code. someone in the future will be searching for a solution to this problem.
  • BoZoBoZo Posts: 6Questions: 0Answers: 0
    it is not a global function, only for my small table where the columns are fix! :)

    [code]
    $.fn.dataTableExt.oApi.fnResetAllFilters = function (oSettings, bDraw/*default true*/) {

    for(iCol = 0; iCol < oSettings.aoPreSearchCols.length; iCol++) {
    if (iCol == 1)
    {
    oSettings.aoPreSearchCols[ iCol ].sSearch = $("#yukHeight").val();
    }
    else if (iCol == 2)
    {
    oSettings.aoPreSearchCols[ iCol ].sSearch = $("#yukWeigth").val();
    }
    else
    {
    oSettings.aoPreSearchCols[ iCol ].sSearch = '';
    }
    }
    //oSettings.oPreviousSearch.sSearch = '';

    if(typeof bDraw === 'undefined') bDraw = true;
    if(bDraw) this.fnDraw();
    }

    [/code]
This discussion has been closed.