3

I have not found a working example where the table data is loaded via javascript, and am getting the oTable.settings is not a function error when trying to initialize the filters. The DT loads properly. Any suggestions would be appreciated.

Thanks, Rick

Here is my code:

<script src="../bower_components/jquery/jquery.js" type="text/javascript"></script>
<script src="../lib/DataTables-1.10.5/media/js/jquery.dataTables.js" type="text/javascript"></script>
<script src="../lib/yadcf-0.8.8/jquery.dataTables.yadcf.js" type="text/javascript"></script>

...

<script type="text/javascript" charset="utf-8">
var ndx=0;
$(document).ready( function () {
    var myTable = $('#example').dataTable({
        "data": data.tables[ndx].data,
        "columns": data.tables[ndx].columns,
        "uHeaders": [],
        "uMeta": []
    });
    yadcf.init(myTable, [
    {column_number : 0},
    {column_number : 1, filter_type: "text"}
    ]);
});

1 Answers1

6

You should use the yadcf init function whenever you use the new datatables capital D constructor only.

When using the lowercase datatables constructor you should use the old yadcf api, $('#example').dataTable({...}).yadcf(...);

So either change $('#example').dataTable({ into $('#example').DataTable({

Or

Instead of calling yadcf.init(... use the

var myTable = $('#example').dataTable({
    "data": data.tables[ndx].data,
    "columns": data.tables[ndx].columns,
    "uHeaders": [],
    "uMeta": []
}).yadcf(...)
Daniel
  • 36,833
  • 10
  • 119
  • 200