Not able to use multi Column search

Not able to use multi Column search

kumar_endeavourkumar_endeavour Posts: 5Questions: 3Answers: 0
edited May 2015 in Free community support

I have created my data table using ajax, following is my code

$(document).ready(function() {
    
     $('#tabledata tfoot th').each( function () {
            var title = $('#tabledata thead th').eq( $(this).index() ).text();
            $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
        } );
    
    
   var table=$("#tabledata").dataTable( {
                                            "bProcessing": false,
                                            "iDisplayLength": 15,
                                            "sAjaxDataProp": "",
                                            "bSearchable": true,
                                            "scrollCollapse": true,
                                            "paging":         true,
                                            "bServerSide": false,
                                            "sAjaxSource": "viewOrder.do?method=listOfOrders",
                                            "bJQueryUI": true,
        
                                            "aoColumns": [
                                                            { "mData": "orderId"},         
                                                            { "mData": "orderType"},         
                                                              { "mData": "status"}
                                                            ]
        
        
       
                                        } ); 
   
   
   table.columns().every( function () {
       var that = this;

       $( 'input', this.footer() ).on( 'keyup change', function () {
           that
               .search( this.value )
               .draw();
       } );
   } );
  
    
   
} );

when i run the code it says table is undefined.

Please suggest me how to do this

Answers

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    First thing to do is to use:

    var table=$("#tabledata").DataTable( {
    

    See the second top FAQ for why.

    Secondly, if that doesn't work, please link to a test page showing the issue, per the forum rules.

    Allan

This discussion has been closed.