DataTables logo DataTables

via Ad Packs
Multiple TableTools on Multiple tables using alternate initialization not working, lone tables work.
  • I have 2 tables on 1 page and a TableTools on each one however the buttons do not work, I have many other single TableTools on many other tables however they're only 1 table, with more than 1 table they do not seem to work, could anyone help find a solution?
  • 13 Comments sorted by
  • Same problem. Two tables, one page. The print button works on both, the xls and csv only work on table one, not on table two.
  • It would work okay. Can either of you give me a link to your page please?

    Allan
  • Unfortunately I can't since it's on my local server, when I get home I can show you the code though
  • I fixed mine by reading other threads.

    I used "fnResizeButtons" as seen here: http://datatables.net/extras/tabletools/api

    I'm using jQuery Tabs which I didn't realize was causing the issue.
  • Here is my javascript:
    $(function(){
    	oTable = $('.dataTable').dataTable({
    		"bJQueryUI": true,
    		"sPaginationType": "full_numbers",
    		"sDom": '<""f>t<"F"lp>'
    	});
    	var oTableTools = new TableTools( oTable, {
    		"sSwfPath": "http://crm_darkreport/js/dataTables/swf/copy_cvs_xls_pdf.swf",
    		"buttons": [
    			"copy",
    			"csv",
    			"xls",
    			"pdf",
    			{ "type": "print", "buttonText": "Print me!" }
    		]
    	} );
    	
    	$('.tabletools').before( oTableTools.dom.container );
    });
    

    and here is my HTML:
    <div class=fix>
    	<div class=fix>
    		<div class=tabletools></div>
    	</div>
    	<div class="table">
    		<div class="head"><h5 class="iFrames">Contacts</h5></div>
                <table cellpadding="0" cellspacing="0" border="0" class="display dataTable" id="example">
                    <thead>
                        <tr>
                            <th>Name</th>                    
                            <th>Address</th>
                            <th>City</th>
                            <th>State</th>
                            <th>Zip</th>
                            <th>Title</th>
    						<th>Email</th>
    						<th>Phone</th>
                        </tr>
                    </thead>
                    <tbody>
    					<?php echo $contactRows; ?>
                    </tbody>
                </table> 
    	</div>
    </div>
    
    
    
    <div class=fix>
    	<div class=fix>
    		<div class=tabletools></div>
    	</div>
    	<div class="table">
    	<div class="head"><h5 class="iFrames">Payments</h5></div>
                <table cellpadding="0" cellspacing="0" border="0" class="display dataTable" id="example2">
                    <thead>
                        <tr>
                            <th>Invoice</th>
                            <th>Payment Date</th>
                            <th>Amount</th>
                            <th>Note</th>
    				    </tr>
                    </thead>
                    <tbody>
    					<?php echo $accountRows; ?>
                    </tbody>
                </table>
    			</div>
            </div>
        </div>
    </div>
    
  • no insight into why it's not working?
  • Looks like it should be working. You say you use fnResizeButtons - how do you use it? Any script errors or anything else? What are the symptoms?

    Allan
  • I personally don't use fnResizeButtons, I tried it but with no avail.
  • And after debugging the JS and code it shows no errors, warnings or notices.
  • I see. It just that you said:

    I used "fnResizeButtons" as seen here: http://datatables.net/extras/tabletools/api

    So, is it in a tab? If so, you will likely need to use the resize function when the tab is made visible. You can do that something like this http://datatables.net/release-datatables/examples/api/tabs_and_scrolling.html (although obviously called fnResizeButtons).

    Allan
  • morrty said that, mine are not in tabs
  • Sorry - in that case, as far as I can see, your code should be working. The only thing that stands out for me is the absolute URL. I'd suggest making that relative otherwise you might run into cross domain issues.

    Allan
  • Could it be to do with the edited sDom?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.

In this Discussion