DataTable columns are not adjusting - tabs

DataTable columns are not adjusting - tabs

solfshrsolfshr Posts: 5Questions: 0Answers: 0
edited November 2010 in General
Hello,

I have several DataTables that I am creating in various tabs with the following code:

[code]
var oTable = $('.paging').dataTable(
{
'iDisplayLength': 5,
'oLanguage' : {'sInfo' : "_START_ - _END_ of (_TOTAL_)"},
'sDom' : '<"top"ip><"cleaner">t',
'bAutoWidth': false,
'sScrollY' : '140px',
'bScrollCollapse' : true
});
[/code]

When I show the tabs the columns are not resizing even though I am using the fnAdjustColumnSizing() function like this after I show the tab content:
[code]
if (oTable.length > 0) {
oTable.fnAdjustColumnSizing();
};
[/code]

If I click on the TH to sort the DataTables re-size the columns properly. What am I doing wrong?

Cassandra

Replies

  • solfshrsolfshr Posts: 5Questions: 0Answers: 0
    edited November 2010
    Hello Allan,

    Your plug-in rocks!!!

    I finally got the function working on the first table of each tab by using the following code:

    [code]oTable = $('div.dataTables_scrollBody>table.paging', newTab).dataTable();[/code]

    Now, I know I can use : $.fn.dataTableExt.iApiIndex to get the index of each table as I have read in other forum posts. However, when I attempt to place the fnAdjustColumnSizing() function in a loop like this:

    [code]
    for(var i = 0; i < oTable.length; i++) {
    $.fn.dataTableExt.iApiIndex = i;
    oTable.fnAdjustColumnSizing();
    }
    [/code]

    I am getting an error:

    a is null
    c=b.getElementsByTagName("table")[0];b...er");b.className=a.oClasses.sFilter;
    jquery.dataTables.min.js
    Line 73

    Is there any way that I can execute the fnAdjustColumnSizing() on each table within the tab?

    Thanks,

    Cassandra
This discussion has been closed.