Resize Table Columns after Dynamic Hide

Resize Table Columns after Dynamic Hide

adisaadisa Posts: 4Questions: 0Answers: 0
edited October 2010 in General
Is there a way to dynamically resize the table after rows are hidden. If I hide rows then refresh the page I get the desired result. If I use sWidth would that give me the desired results or is there another way? I tried using fnAdjustColumnSizing as shown below but it didn't seem to work.


$(document).ready(function () {
var oTable = $('#example').dataTable({
"sScrollY": "200px",
"bPaginate": false
});

$(window).bind('resize', function () {
oTable.fnAdjustColumnSizing();
});
});

function fnShowHide( iCol )
{
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var oTable = $('#example').dataTable();

var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis(iCol, bVis ? false : true);

}

Replies

  • jp_noronhajp_noronha Posts: 59Questions: 0Answers: 0
    edited September 2011
    Hi adisa,

    did you try like this:

    [code]
    function fnShowHide( iCol )
    {
    /* Get the DataTables object again - this is not a recreation, just a get of the object */
    var oTable = $('#example').dataTable();

    var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
    oTable.fnSetColumnVis(iCol, bVis ? false : true);
    oTable.fnAdjustColumnSizing();
    }
    [/code]
This discussion has been closed.