2

i'm trying to use TableTools to export the datatable (example) into excel or csv , I prefer Excel. but with this code below it's not even show me the icons (export/print/csv/..) I made several changes but nothing helped . . what am I doing wrong? what am I missing? there is any example of how to implement it? I also did it exactly as they do in the official site and it's still not working.

<link rel="stylesheet" type="text/css" href="assets/jquery.dataTables.css">

<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.0/css/jquery.dataTables.css">
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script>

	$.ajax({
	  type: "POST",
	  url: "server_processing_harigot.php",
	  data: {
	    str: str,
	    hotel_id: hotel_id
	  },
	  cache: false,
	  success: function(result) {
	    data = JSON.parse(result);
	    $.each(data, function(index, data) {
	      //!!!--Here is the main catch------>fnAddData
	      $('#example').dataTable().fnAddData([
	        data.phone_number,
	        data.name,
	        data.client_id,
	        data.employee

	      ]);

	    });

	  }

	});
	$('#example').dataTable({
	  "sDom": 'T<"clear">lfrtip',
	  "oTableTools": {
	    "sSwfPath": "swf/copy_csv_xls_pdf.swf"
	  }
	});
<table width="100%" id="example" class="display" cellspacing="0">
  <caption><strong>	example	</strong>
  </caption>
  <thead>
    <tr>
      <th>phone_number</th>
      <th>name</th>
      <th>client_id</th>
      <th>employee</th>


    </tr>
  </thead>
  <tbody id="tablebody">
  </tbody>
</table>

any idea?

1 Answer 1

5

You're missing the reference for dataTables.tableTools.js and dataTables.tableTools.css.

See here for examples

EDIT: This feature has now moved over to combination of using Buttons and Select extensions. See here.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks alot ! i watched the example .. i missed the dataTables.tableTools.js and the swf path.
what should be the swf path, where can i get the swf file

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.