1

im using jquery Datatable plugin, and following the How can I export tables to excel from a webpage to add several button(copy/csv/excel/pdf/print) above my table, but export action(copy&csv&excel&pdf) does not work for me, below is my main code:

<head>
<style type="text/css" title="currentStyle">
    @import "../../media/css/demo_page.css";
    @import "../../media/css/demo_table.css";
    @import "media/css/TableTools.css";
</style>
<script type="text/javascript" charset="utf-8" src="../../media/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8" src="media/js/ZeroClipboard.js"></script>
<script type="text/javascript" charset="utf-8" src="media/js/TableTools.js"></script>

<script type="text/javascript" charset="utf-8">


$(document).ready( function () {
    $('#example').dataTable( {
        "sDom": 'T<"clear">lfrtip',
            "oTableTools": {
                    "sSwfPath": "/swf/copy_cvs_xls_pdf.swf"
                }
        });
    });
 </script>
</head>

any help? in addition:what i want to do is let these buttons to work as "Copy/Print/Save" work in this page

4
  • Which browser are you working with? Commented Oct 10, 2013 at 11:51
  • @JannisHanke am using Chorme? Commented Oct 10, 2013 at 12:40
  • Make sure your path to .swf is right. Is the configuration file also in the right folder? Commented Oct 10, 2013 at 13:41
  • i can not understand configuration file? i just import 4 js and 3 css files as above code displayed, and the path of .swf is right(i can get this .swf-based buttons but they dunt work except "Print" button), thank your reply! Commented Oct 10, 2013 at 15:23

3 Answers 3

1

try this:

"oTableTools": {
    "sSwfPath": "copy_csv_xls_pdf.swf",
    "aButtons": [{
        "sExtends": "collection",
        "sButtonText": "Export",
        "aButtons": [{
            'sExtends': "csv"
            },
            {
                'sExtends': "xls"
            },
            {
                'sExtends': "pdf"
            },
            {
                'sExtends': "print"
            },
        ],
    }],
}
Sign up to request clarification or add additional context in comments.

Comments

0
     var oTable = $('#tblView').dataTable({

                       "bJQueryUI": true,
                       "sScrollX": "500px",
                       "sPaginationType": "full_numbers",
                       //"sDom": 'T<"clear">lfrtip',
                      // "sDom": '<"clear">lfrtipT',
                       "sDom": '<"H"lTfr>t<"F"ip>',
                       "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
                       "iDisplayLength": 10,
                       "oTableTools": {
                           "sSwfPath": "../Content/swf/copy_csv_xls.swf",
                           "aButtons": [
                            {
                                "sExtends": "xls",
                                "mColumns": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22],
                                "sPdfOrientation": "landscape",
                                "sButtonText": "Export to Excel",
                            }
                           ]
                       }, "bDestroy": true,
                       "aoColumnDefs": [{
                           'bSortable': false,
                           'aTargets': [0, 1]
                           }],


                   });


use css and script
<link href="~/Content/themes/base/demo_page.css" rel="stylesheet" />
<link href="~/Content/themes/base/demo_table_jui.css" rel="stylesheet" />
<link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />
<link href="~/Content/themes/base/TableTools.css" rel="stylesheet" />
<script src="~/Scripts/js/jquery-1.8.2.js"></script>
<script src="~/Scripts/js/jquery.ui.core.js"></script>
<script src="~/Scripts/js/jquery.ui.widget.js"></script>
<script src="~/Scripts/js/jquery.ui.datepicker.js"></script>
<script src="~/Scripts/js/jquery.dataTables.js"></script>
<script src="~/Scripts/js/jquery.ui.dialog.js"></script>
<script src="~/Scripts/js/dataTables.tableTools.min.js"></script>

Comments

0

I just implemented solution which works on client-side and without flash: https://github.com/zedxter/DataTablesCSV

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.