Exporting the datatable to csv,xls,pdf and print option

Exporting the datatable to csv,xls,pdf and print option

shivarhamshivarham Posts: 3Questions: 0Answers: 0
edited March 2013 in TableTools
Can anyone please tell me the step by step procedure for including the button options of Exporting the datatable to csv,xls,pdf and adding print options using the tabletools plugin for the following code.
(Im new to this entire technology of jquery and javascript. Please clearly tell me the steps.)

Please tell me what plugin should i include.
Please tell from where i can download the plugin.
Tell me the code tht is required for this option and where to place the code exactly as per my table id.




My request









 
Status
Date
Title
Service Type
Accounts







Submitted
03/09/2013
Title1
10

468990076754



Submitted
03/11/2013
Title2
9

468990076754



Submitted
03/12/2013
Title3
8

468990076754



Submitted
03/15/2013
Title0
7

468990076754



Pending
03/20/2013
Title4
6

468990076754



Progress
03/21/2013
Title5
7

468990076754



Submitted
03/22/2013
Title6
8

468990076754



Submitted
03/23/2013
Title7
3

468990076754



Submitted
03/24/2013
Title8
2

468990076754



Pending
03/25/2013
Title9
1

468990076754










Thank you. :)

Replies

  • equisdeequisde Posts: 34Questions: 0Answers: 0
    edited March 2013
    Hi!

    You'll need to add TableTools in order to have this feature. You can download TableTools from here:

    http://www.datatables.net/extras/

    Once downloaded you'll need to add several files to your project and reference them in the header:

    ----- Scripts------------
    1.- TableTools.min.js
    2.- ZeroClipboard.js

    -------CSS-------------

    3.- TableTools_JUI.css
    4.- TableTools.css


    Once is done you should initialise your table prior to display it. Please note that the file "copy_csv_xls_pdf.swf" must be included in your project.

    This is the basic example for initialising the table using TableTools. This code should be placed at the top of your source code before label

    [code]$(document).ready( function () {
    $('#example').dataTable( {
    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
    "sSwfPath": "/swf/copy_csv_xls_pdf.swf"
    }
    } );
    } );[/code]

    Please refer to the documentation to get more examples using TableTools: http://www.datatables.net/extras/tabletools/examples
  • shivarhamshivarham Posts: 3Questions: 0Answers: 0
    Hi equisde,

    Thanks a lot for ur help.
    I modified my header as per ur instructions. I have downloaded Datatables version 1.9.4
    I have all the project files in the same folder in root. No subfolders.
    When i run my html im getting an error as

    "Table tools 2 require Datatables 1.9.0 or newer version."

    Can u pls check whether the following code is correct. Should i include anyother files in header or should there be any modifications needed in my exisiting code.


    My request






    @import "TableTools_JUI.css";
    @import "TableTools.css";




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







    Thanks
  • equisdeequisde Posts: 34Questions: 0Answers: 0
    Hi,

    Take a look at this thread. I had the same problem

    http://www.datatables.net/forums/discussion/12829/warning-tabletools-2-requires-datatables-1.9.0-or-newer-on-internet-explorer-89#Item_6
  • equisdeequisde Posts: 34Questions: 0Answers: 0
    Sorry i forgot correct your code

    [code]
    My request











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


    [/code]
  • shivarhamshivarham Posts: 3Questions: 0Answers: 0
    Equisde,

    I copied and pasted ur code in my header.
    I'm getting the same error in the dialog box.
    But before copying ur code, the webpage was blank after that error message and after using ur code my
    table present in the body tag is displayed.

    "Table tools 2 require Datatables 1.9.0 or newer version."
    :(
    Please help.

    Thanks,
    Siva Ram R
  • equisdeequisde Posts: 34Questions: 0Answers: 0
    What browser are you using? Sometimes IE9 is not able to load TableTools correctly

    See this ---> http://www.datatables.net/forums/discussion/12829/warning-tabletools-2-requires-datatables-1.9.0-or-newer-on-internet-explorer-89#Item_6
This discussion has been closed.