TableTools buttons not working

TableTools buttons not working

tarunsunejatarunsuneja Posts: 6Questions: 1Answers: 0
edited August 2015 in Free community support

I have been trying to implement DataTable table tools since last 2 days, but not getting any success. I have tried various forums, but no solution found so far which works for me.

Some observations:

  • Buttons are displayed correctly
  • Print, Select all, Select none button works fine
  • Copy button says 0 rows selected
  • PDF / CSV / Excel buttons do not respond at all.

In some forums, similar code is working perfectly fine, but not for me.

I am using these js files:

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://cdn.datatables.net/1.10.8/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.8/js/dataTables.bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/responsive/1.0.7/js/dataTables.responsive.min.js"></script>
<script src="https://cdn.datatables.net/tabletools/2.2.4/js/dataTables.tableTools.js"></script>

And this is my table initialization:

dt = $('#MyDataTable').DataTable({
responsive: true,
"data": resultData,
"displayLength": 100, //-1 = All,
"lengthChange": false, // To show page size dropdown
"destroy": true,
"scrollX": false,
"scrollY": "400px",
"scrollCollapse": true,
"sortClasses": false,
"order": [[0, "desc"]],
"columns": seawdarasListColumnsData,
"columnDefs": [{
    "targets": -1,
    "data": null,
    "render": function (data, type, row) {

        var htmlText = '<span title="Click to mark attendance for this Sewadar"';
        htmlText += 'class="btn btn-success btn-xs" >' + btnQuickAttendanceText + '</span>';

        htmlText += ' <span title="Click to mark \'Manual\' attendance for this Sewadar"';
        htmlText += 'class="btn btn-success btn-xs" >' + btnManualAttendanceText + '</span>';

        htmlText += ' <span title="Click to see Attendance Report for this Sewadar"';
        htmlText += 'class="btn btn-success btn-xs" >' + btnPersonAttendanceReportText + '</span>';


        return htmlText;
    }
}],
//select: true,
"dom": 'T<"clear">lfrtip',
"tableTools": {
    "sSwfPath": "https://cdn.datatables.net/tabletools/2.2.4/swf/copy_csv_xls.swf"
}
});

This was my initial code. I found from somewhere this piece of code, but this also didn't help me.

"tableTools": {
    "sSwfPath": "https://cdn.datatables.net/tabletools/2.2.4/swf/copy_csv_xls.swf",
 "sRowSelect": "os",
    "sRowSelector": 'td:first-child',
    "aButtons": [
         "copy",
         "csv",
         "xls",
         {
             "sExtends": "pdf",
             "fnCellRender": function (sValue, iColumn, nTr, iDataIndex) {
                 //extract the value of the select  
                 if (iColumn === 7) {
                     var val = $(sValue).find('select').val();
                     return (val !== '') ? val : 'not set';
                 }
                 //create a dummy text for the HTML-link
                 if (iColumn === 8) {
                     return 'click';
                 }
                 return sValue;
             }
         },
         "print",
         "select_all",
         "select_none"
    ]
   }

I really need to sort this out as my complete project is setup now. i just need to have these export features so that I can deliver my project.

For your convenience, I have also created a jsbin here:

Answers

This discussion has been closed.