waris
waris

Reputation: 204

datatable tabletools csv not working

This code was working fine , but without changing anything the export button is not displaying.

I have inserted the libraries on right location:

    $this->document->add_css('jquery.datetimepicker.css');
    $this->document->add_css('dataTables.tableTools.min.css');
    $this->document->add_js('jquery.datetimepicker.js');
    $this->document->add_js('jquery.dataTables.min.js');
    $this->document->add_js('dataTables.tableTools.js');

this is my code :

  $(".table-dashboard").DataTable({
        "dom": "T<\'clear\'>lfrtip",
        initComplete: function(){
            $(".scrollable-list").before($(".DTTT_container"));
            $(".DTTT_container").css("margin-bottom", "-33px");
        },
        bFilter: false,
        "aoColumnDefs":
        [
            {
                "bSortable": false,
                "aTargets": [$(this).find("thead tr th").length - 1]
            }
        ],
        "oTableTools":
        {//        "sSwfPath": "'.base_url(SYSTEM_MEDIA . "swf/copy_csv_xls_pdf.swf").'",
            "sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf",
            "aButtons":
            [ 
                {
                    "sExtends"      :   "csv",
                    "sButtonText"   :   "Export CSV <i class=\'fa fa-file-excel-o\'></i>",
                    "sButtonClass"  :   "btn btn-primary"
                }
            ]
        }
    });

Upvotes: 0

Views: 467

Answers (1)

waris
waris

Reputation: 204

I`ve founded by myself solution, i added some these libraries which were missing.

<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/buttons/1.4.2/js/buttons.print.min.js"></script>

Script:

   dom: 'Bfrtip',
        initComplete: function(){
            $(".scrollable-list").before($(".DTTT_container"));
            $(".DTTT_container").css("margin-bottom", "-33px");
        },
        bFilter: false,
        "aoColumnDefs":
        [
            {
                "bSortable": false,
                "aTargets": [$(this).find("thead tr th").length - 1]
            }
        ],
        buttons: [
            {
                extend: "csv",
                text:  "Export CSV",
                className: "btn btn-primary"
            }
        ]        

Upvotes: 0

Related Questions