Resize Table Columns after Dynamic Hide
Resize Table Columns after Dynamic Hide
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);
}
$(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);
}
This discussion has been closed.
Replies
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]