Search code examples
jqueryexceldatatabledatatablestabletools

Datatable - Tabletool Exporting all data to Excel rather the searched result


I'm using dataTable & TableTool. Suppose I've 57 entries in the table like

 <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
    <thead>
        <tr>
            <th>Rendering engine</th>
            <th>Browser</th>
            <th>Platform(s)</th>
            <th>Engine version</th>
            <th>CSS grade</th>
        </tr>
    </thead>
    <tbody>
        <tr class="odd_gradeX">
            <td>Trident</td>
            <td>Internet Explorer 4.0 (focus once)</td>
            <td>Win 95+</td>
            <td class="center">4</td>
            <td class="center">X</td>
        </tr>
........................................................

Then I added all the script

<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/ZeroClipboard.js"></script>
<script type="text/javascript" charset="utf-8" src="js/TableTools.js"></script>

Next initialized with

 <script type="text/javascript" charset="utf-8">
            $(document).ready( function () {
                $('#example').dataTable( {
                    "sDom": 'T<"clear">lfrtip',
                    "oTableTools": {
                        "sSwfPath": "swf/copy_csv_xls_pdf.swf" }
                } );
            } );
        </script>

Then I fetched the page on localhost. So it worked. It can print,it can take data to excel. But it's always exporting 57 entries after I search for something.

Suppose I searched 'something' & datatable returned me 8 entries that matched. Now I want to export this 8 data to excel not 57 entries. In this Example link it's working the way I want to, but not on my localhost. Is there anything that I'm missing? Or can it be a problem of the version for tabletool that I'm using? I'm not sure which version I'm using currently.


Solution

  • I don't know what was wrong but got the solution. Checked the dataTable site with firebug. They are using a js file named 'complete.min.js'

    Downloaded that, used the complete.min.js before jquery.dataTables.min.js Removed the ZeroClipboard.js script.

    And everything worked fine then.