Individual INPUTS search

Individual INPUTS search

seb69400seb69400 Posts: 2Questions: 1Answers: 0

Hello,

I am French and I have a problem with my datatable.

I have some columns on my datatable, and I want to be able to make a search with external inputs.

So I have 5 columns, 5 inputs type of text on a different div than datatable.

How can I make a filter or a search for each inputs to an individidual column ?

ex : an intput can make a filter or search only for the column 'name', or by clicking a button ?

I see a lots of example and worked for me....

Answers

  • seb69400seb69400 Posts: 2Questions: 1Answers: 0
    edited December 2017

    for example, with an INPUT with id="nom", this doesn't work :

    $(document).ready(function() {
    $('#nom').change(function (e) {
    dataTable.search();
    dataTable.draw();
    });
    var dataTable = $('#employee-grid').DataTable( {
    searching:false,
    bFilter:true,
    "sPaginationType": "full_numbers",

                    "processing": true,
                    "serverSide": true,
                    "ajax":{
                        url :"data-grid-data.php", // json datasource
                        type: "post",  
                        data:
                        {
                            'nom':function(){return $("#nom").val(); } 
                        },
                        error: function(){  // error handling
                            $(".employee-grid-error").html("");
                            $("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
                            $("#employee-grid_processing").css("display","none");                           
                            }
                        }
                    });         
            });
    
  • allanallan Posts: 63,335Questions: 1Answers: 10,437 Site admin

    column().search() can be used to search individual columns. There is an example available here.

    Allan

This discussion has been closed.