问题
With following imports, I have my datatable functioning:
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css"
href="<c:url value="css/jquery.themeroller.css" />" />
<!-- TableTools CSS -->
<link rel="stylesheet" type="text/css"
href="<c:url value="css/TableTools_JUI.css" />" />
<!-- jQuery -->
<script type="text/javascript" charset="utf8"
src="jQuery/jquery-1.8.2.min.js"></script>
<!-- DataTables -->
<script type="text/javascript" charset="utf8"
src="jQuery/jquery.dataTables.min.js"></script>
<!-- TableTools -->
<script type="text/javascript" charset="utf8"
src="jQuery/TableTools.js"></script>
<script type="text/javascript" charset="utf8"
src="jQuery/ZeroClipboard.js"></script>
I am now trying to have tabletools options (print, save, copy, xls buttons) for my table. I have inserted
oTable = $('#myTable').dataTable({
"bJQueryUI" : true,
"iDisplayLength" : 10,
"sPaginationType" : "full_numbers",
"aaSorting" : [ [ 7, "desc" ] ],
"sDom": '<"H"lfr>t<"F"ip>' )}
but there is no change.
Do I have to change any of import queries or add css or something to get tabletools working? I have tried "sDom":
"sDom": '<"H"lfr>t<"F"ip>'
"sDom": '<"H"lfrT>t<"F"ip>',
"sDom": '<"H"lfr>t<"F"ip>T',
I had this for sSwfPath:
"C:/JAVA ENVIRONMENT/Workspace/Test/DisplayTable3/DataTables-1.9.4/extras/TableTools/media/swf/copy_cvs_xls_pdf.swf"
still nothing
Thanks in advance
回答1:
Change "C:/JAVA ENVIRONMENT/Workspace/Test/DisplayTable3/DataTables-1.9.4/extras/TableTools/media/swf/copy_cvs_xls_pdf.swf" to a web path on your webserver. It's a common problem related to swf security. Found it on DataTables website. Also you can't redeclare sDom.
This is my working code with TableTools and ColVis:
$(document).ready( function () {
$('#results').dataTable( {
"sDom": 'T<"clear">Clfrtip',
"oTableTools": {
"sSwfPath": "http://192.168.78.7/cdtc/app/custom/libs/DataTables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
来源:https://stackoverflow.com/questions/18513430/datatable-tabletools-initialisation