How do I set value for Jquery Datatables filter?

2

I have my input and button

<input id="gridSearch" type="text" /> <button id="filter" class="btn btn-default">Buscar</button>

and my table

$.fn.dataTable.ext.legacy.ajax = true;
var grid = $("#gridCustomer").DataTable({
    "language": {
        "sProcessing": '<img src="/Scripts/loadingBgBlack.GIF" /> Loading...'
    },
    "bFilter": false,
    "bLengthChange": false,
    "processing": true,
    "serverSide": true

How do I set the value to filter on the grid?

$('#filter').click(function (e) {

    var searchValue = $("#gridSearch").val();

});

Why did I do this?

Why do I want to put the input in another position, and I want it to search only when you click on "Search".

Then I removed what comes standard, using "bFilter": false and manually adding my own input with button

    
asked by anonymous 09.09.2014 / 03:05

1 answer

1

Friend.

In order for you to do this, you will have to pass the value of your field to the source that is loading the information.

In my case, I use PHP to load the information. In the PHP Source there is a $_GET ['sSearch'] which is the value of the Default field.

Just replace it with the value of the field you are using - &sSearch=SEU_VALOR

    
17.09.2014 / 22:16