Tabletools buttons not working solution

Tabletools buttons not working solution

XereuXereu Posts: 3Questions: 0Answers: 0

Hello Everyone, I was having issues getting tabletools flash buttons to work. The fnResizeButtons() function was supposed to fix it but the code on the documentation wasn't working for me. The reason for which it wasn't working is because my jQueryUI tabs have extra lines of code to get the browser to remember the last opened tab. I have multiple tabs and sub tabs with several datatable instances.

This is the code at the API documentation

$("#tabs").tabs( {
        "active": function(event, ui) {
            var jqTable = $('table.display', ui.panel);
            if ( jqTable.length > 0 ) {
                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();
                }
            }
        }
    } );

This is what I had to change to get it to work with my tabs

$("#tabs").tabs({
    activate: function (e, ui) { 
       $.cookie('#tabs selected-tab', ui.newTab.index(), { path: '/' }); 
        var jqTable = $('table.dataTable:visible', ui.panel);
            if ( jqTable.length > 0 ) {
                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();
                }
      }
    }, 
    active: $.cookie('#tabs selected-tab')
});

Hope this helps another soul find peace.

This discussion has been closed.