Howto add custom search field

Howto add custom search field

sangprabvsangprabv Posts: 9Questions: 0Answers: 0
edited August 2011 in General
I want to add a custom search field at the left side of the original search field. How to do that?

Replies

  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    Put your custom filter in place using standard DOM / jQuery techniques and then use fnFilter ( http://datatables.net/api#fnFilter ) to apply the filter to DataTables.

    Allan
  • sangprabvsangprabv Posts: 9Questions: 0Answers: 0
    Thanks for the response. I have read some articles about DOM but until now I still don't know how to implement it correctly. And for the fnFilter, currently I apply the fnServerData approach. Using this code
    [code]
    "fnServerData": function ( sSource, aoData, fnCallback ) {
    aoData.push( { "name": "msisdn", "value": $('#msisdn').val() } );
    aoData.push( { "name": "msgdata", "value": $('#msgdata').val() } );
    $.ajax({
    "dataType": 'json',
    "type": "GET",
    "url": "../log/ajax.php",
    "data": aoData,
    "success": fnCallback
    });
    },
    [/code]
    [code]
    $('#msisdn').change(function() { oTable.fnDraw(); });
    $('#msgdata').change(function() { oTable.fnDraw(); });
    [/code]
    Currently the query perform direclty when we type something in the field. Is it possible to add a button and only do the query after we hit the button? Thanks
  • allanallan Posts: 63,400Questions: 1Answers: 10,452 Site admin
    Yes - you can do something like this plug-in which will filter only when the return key is pressed: http://datatables.net/plug-ins/api#fnFilterOnReturn . You can add a button to do something similar if you want.

    Allan
  • sangprabvsangprabv Posts: 9Questions: 0Answers: 0
    Many thanks for the help Allan
This discussion has been closed.