Tabletools doesn't work

Tabletools doesn't work

drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
edited November 2012 in General
I am trying to use tabletools plugin for the datatables I already have. I have included zeroclipboard.js and also the tabletools.min.js file in my jsp page. I have created a folder swf under WEB-INF and added the copy_cvs_xls_pdf.swf file in that directory. I am using

[code]
[/code] to get the path

I have included the path as

[code]
"oTableTools": {
"sSwfPath": ""
} [/code]
I don't get any errors when I look at firebug but still all the options are disabled except the print option. Any help would be greatly appreciated

Replies

  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    Can some one help me with this ? I am stuck here since 2 days and I can't get it working. I have tried several times with different paths but doesn't seem to work at all
  • allanallan Posts: 63,302Questions: 1Answers: 10,431 Site admin
    edited November 2012
    1. Link us to the page should the issue like in the 'New Discussion' instructions :-)
    2. Look at your server's error log. I'd bet you are getting a 404 error on the swf.

    Allan
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    edited November 2012
    Thanks for the reply Allan, I don't see any error in the firebug or in the server's error log. When I change the path of the swf file, then I get 404 error else i don't see any error in the console.
  • allanallan Posts: 63,302Questions: 1Answers: 10,431 Site admin
    Okay in that case I'm guessing (can't be sure since I can't see it) that you are creating the table in a hidden element - in which case you need to use http://datatables.net/extras/tabletools/api#fnResizeButtons when you make the table visible so the Flash buttons have height / width.

    Allan
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    Link to the debug, if this will be helpful. http://debug.datatables.net/idazof
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    edited November 2012
    I have a div id like this
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    Thanks for the help Allan, I have style set to display:none for the div and I have removed that and now the buttons are working fine
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    edited November 2012
    Allan,

    I have just another problem, I need to keep the div tag, and I am trying to use your example given above, for some reason I don't get the functionality working.
    I have this code, and jqTable[0] seems to be null when I try to alert it

    [code]
    var jqTable = $('table.display, ui.panel');
    console.log(jqTable);
    var oTableTools = TableTools.fnGetInstance( jqTable[0] );

    if ( oTableTools != null && oTableTools.fnResizeRequired() )
    {
    /* A resize of TableTools' buttons and DataTables' columns is only required on the
    * first visible draw of the table
    */
    jqTable.dataTable().fnAdjustColumnSizing();
    oTableTools.fnResizeButtons();
    }

    [/code]

    console.log[jqTable] does print

    [quote]
    [prevObject: e.fn.e.init[1], context: #document, selector: "table.display, ui.panel"]
    context: #document
    length: 0
    prevObject: e.fn.e.init[1]
    selector: "table.display, ui.panel"
    __proto__: Object[0]
    [/quote]
  • allanallan Posts: 63,302Questions: 1Answers: 10,431 Site admin
    I guess you don't have any elements which match that selector?
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    edited November 2012
    What should go into the jqTable variable ?
    Since my table id is datatablesTableID should I have to like use it like
    $('datatablesTableID', ui.panel) or something like that ?
  • allanallan Posts: 63,302Questions: 1Answers: 10,431 Site admin
    Without seeing the page I honestly can't say for certain but how about $('#datatablesTableID') ...
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    edited November 2012
    Yes, I tried that and it didn't work either.
    Does the debug help ? http://debug.datatables.net/okofug

    I have placed some debug statements and found that oTableToolsValue is indeed null and doesn't go into the if loop

    [code]
    var jqTable = $('#datatablesTableID');
    console.log(jqTable);
    if ( jqTable.length > 0 ) {
    console.log(jqTable[0]);
    var oTableTools = TableTools.fnGetInstance( jqTable[0] );
    console.log(oTableTools);
    if ( oTableTools != null && oTableTools.fnResizeRequired() )
    {
    /* A resize of TableTools' buttons and DataTables' columns is only required on the
    * first visible draw of the table
    */
    jqTable.dataTable().fnAdjustColumnSizing();
    oTableTools.fnResizeButtons();
    }
    }
    [/code]

    output for 3 console.log statements I have put
    [quote]
    [table#datatablesTableID]

    null
    [/quote]
  • allanallan Posts: 63,302Questions: 1Answers: 10,431 Site admin
    That looks like it should work to me as long as the table is visible at that point.

    If oTableTools in the above code is null then TableTools doesn't know what your table is. I really would need to see a working example to even stand a chance of being able to offer any more help.

    Allan
This discussion has been closed.