New to datatables. How do I add settings when using "var table = $('#example').DataTable();"

New to datatables. How do I add settings when using "var table = $('#example').DataTable();"

bigracefan18bigracefan18 Posts: 15Questions: 2Answers: 0

I'm trying to find an example of how to add the report setting using var table. I've added my own plugin for searching. But now I can't figure out how to add stuff like hidden rows, tableTools, pagination...

$(document).ready(function () {

        var table = $('#example').DataTable();
        $('#grade').change(function () {
            table.draw();
        });
        $('#bdate').change(function () {
            table.draw();
        });
    });

I'm trying add stuff like this;

      "aaSorting": [[4, "asc"]],
            "aoColumns": [
        null, 
        null, 
        { "bVisible": false },
        { "bVisible": false },
        { "iDataSort": 3 },
        null,
        null]

Answers

  • bigracefan18bigracefan18 Posts: 15Questions: 2Answers: 0

    Answered my own question. Here's the result if anyone's interested. Couldn't get the "bFilter": false to work thou.

        $(document).ready(function () {
            var table = $('#example').DataTable({
                "aaSorting": [[4, "asc"]],
                "bAutoWidth": true,
                "bPaginate": true, 
                "bJQueryUI": true,
                "sDom": 'T<"H"fr>t<"F"ip>',
                "aoColumns": [
            null, //first column
            null, //second column
            { "bVisible": false },
            { "iDataSort": 2 },//iDataSort is used to sort the data from another field. in this case it's sorting on the hidden date field
            null,//sixth column
            null//seventh column
                ]
            });
    
            $('#grade').change(function () {
                table.draw();
            });
    
            $('#bdate').change(function () {
                table.draw();
            });
        });
    
This discussion has been closed.