Which to use DataTable or dataTable?

Which to use DataTable or dataTable?

ibdfariaibdfaria Posts: 15Questions: 4Answers: 0

I was first using dataTable() (jquery object) which was working just fine, until I had to use table.column() and other similar methods. And so, I changed to DataTable() (api). Now methods like table.column() work, but other things don't. For example the plugin fnSetFilteringDelay does not work.

This is how I was using the filtering delay:

$(selector).dataTable().fnSetFilteringDelay(800);

Once I changed it to DataTable, I get the following error:

$(...).DataTable(...).fnSetFilteringDelay is not a function

Should I be able to accomplish the same thing whether I use the api or the jquery object? Or one has advantages over the other?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,020Questions: 1Answers: 10,555 Site admin
    Answer ✓

    $().dataTable() gives you the legacy API (fnSetFilteringDelay is a legacy API method)

    $().DataTable() gives you the modern API.

    The best solution would be to rewrite the legacy plug-in to use the new API.

    You can use both forms:

    var table = $('#myTable').DataTable( { ... } );
    var legacyTable = $('#myTable').dataTable();
    

    Allan

  • ibdfariaibdfaria Posts: 15Questions: 4Answers: 0

    Thanks Alan.

This discussion has been closed.