Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

table.columns is not a function in datatable.js

<script>      jQuery(document).ready(function () {           $('#sample_3 tfoot th').each(function () {              var title = $('#sample_3 thead th').eq($(this).index()).text();              $(this).html('<input type="text" placeholder="Search ' + title + '" />');         });          // DataTable         var table = $('#sample_3').dataTable();          // Apply the filter         table.columns().eq(0).each(function (colIdx) {              $('input', table.column(colIdx).footer()).on('keyup change', function () {                  table                     .column(colIdx)                     .search(this.value)                     .draw();             });         });      }); </script> 

I got table.columns is not a function js error , what is missing i am not understand.

source : https://datatables.net/examples/api/multi_filter.html

like image 374
user3090790 Avatar asked Jun 20 '14 11:06

user3090790


1 Answers

Try changing

var table = $('#sample_3').dataTable(); 

to

var table = $('#sample_3').DataTable(); 

... that is, capitalize the DataTable(). Source: https://datatables.net/manual/api#Accessing-the-API

like image 108
sk29910 Avatar answered Sep 17 '22 20:09

sk29910