fnFilter callback?

fnFilter callback?

someansomean Posts: 4Questions: 0Answers: 0
edited March 2011 in General
Hi,

I am wondering if there is any way to implement a callback once the fnFilter() has been completed? The data in my datatable was fetched from MySQL by php script using server side processing.

Basically I have implemented the "Show and hide details about a particular record" feature from the examples and I want the response row from fnFilter() to be "open", saves one click for the user.

Can I do this? I am still quite new to Javascript. Many thanks for any help.


@at299

Replies

  • someansomean Posts: 4Questions: 0Answers: 0
    any1, please?

    Thank you very much.


    @at299
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    fnFilter is a synchronous function - so when it completes the table has been filtered. So:

    [code]
    oTable.fnFilter( 'whatever' );
    doSomething();
    [/code]
    will do it.

    The only exception to this is if you are using server-side processing - when the draw becomes asynchronous. In which case you can use fnDrawCallback and oSettings.bFiltered in the callback.

    Allan
  • heruanheruan Posts: 7Questions: 0Answers: 0
    I have server-side processing and I'd like to bind a callback only on a specific fnFilter call. Is it possible?
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    There are several ways of doing it, but which one will depend upon what you are doing.

    1. Based on the code above:

    [code]
    oTable.fnFilter( filter );
    if ( filter === "whatever" ) {
    doSomething();
    }
    [/code]

    2. Or you could listen for the 'filter' event ( http://datatables.net/docs/DataTables/1.9.0/#filter ) and again do an 'if' condition checking for the filter value

    3. Or you could bind an event listener to the filtering input looking for the value

    Allan
This discussion has been closed.