0

Trying to use Jquery DataTable plugin, calling api function

column()

on datatable object errors out

Uncaught TypeError: undefined is not a function

Created plunker link http://plnkr.co/edit/LymRnduvhXHYfiqeDio6?p=preview my code

$(document).ready(function(){   
    var table=$('#myTable').dataTable( {
         "scrollX": true,
         "dom": '<"toolbar">frtip'
       });
  table.column(3).search('1998').draw();
});

call to function columns on table object errors out, api link http://datatables.net/reference/api/column()

what is wrong in my code? I am using the 1.10.2 version.

1 Answer 1

3

To get the api reference you need to use

$(document).ready(function () {
    $('#myTable').dataTable({
        "scrollX": true,
            "dom": '<"toolbar">frtip'
    });
    var table = $('#example').DataTable();
    table.column(3).search('1998').draw();
});

Demo: Plunker

API

The API can be accessed through the following methods:

$( selector ).DataTable();
$( selector ).dataTable().api();
new $.fn.dataTable.Api( selector );
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you it worked, var table = $('#example').DataTable(); should be var table = $('#myTable').DataTable();
@ArunP Johny it is not wokring for me. same issue continued. using jquery datatable 1.9
Thank you, I was fighting this for a while. I missed the whole upper case lower case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.