How to reset the table width when using kike table plugin?
How to reset the table width when using kike table plugin?
bbarani
Posts: 32Questions: 0Answers: 0
Hi,
I am using kike table plugin to expand / shrink the column width dynamically. Everything seems to work fine except for the fact that when the column width is reduced the table width is not getting reduced hence the last column of the table occupies the available extra width.
Is there a way to reset the column width back to original column width?
I have sScrollx set to 100%
"sScrollX": "100%",
I have a function to reset the table back to its original width.
function resizeTable(tableId)
{
var oTable = $("#" + tableId).dataTable();
var oSettings = oTable.fnSettings();
oSettings.oScroll.sX = "840px"; // <- updated!
oTable.fnDraw(false);
}
I tried the above code to reset the scroll x value on click of a button but this doesnt seem to have any effect with respect to the width of the table. Can someone please let me know best possible way to fix this issue?
Thanks,
Barani
I am using kike table plugin to expand / shrink the column width dynamically. Everything seems to work fine except for the fact that when the column width is reduced the table width is not getting reduced hence the last column of the table occupies the available extra width.
Is there a way to reset the column width back to original column width?
I have sScrollx set to 100%
"sScrollX": "100%",
I have a function to reset the table back to its original width.
function resizeTable(tableId)
{
var oTable = $("#" + tableId).dataTable();
var oSettings = oTable.fnSettings();
oSettings.oScroll.sX = "840px"; // <- updated!
oTable.fnDraw(false);
}
I tried the above code to reset the scroll x value on click of a button but this doesnt seem to have any effect with respect to the width of the table. Can someone please let me know best possible way to fix this issue?
Thanks,
Barani
This discussion has been closed.
Replies
[code]
function resizeDataTable(dataTableid){
$("#" + dataTableid).removeClass('kiketable-colsizable'); // Remove kike column class
var oTable = $("#" + dataTableid).dataTable();
$(oTable).css({ width: $(oTable).parent().width() }); // Perform datatable functions
oTable.fnAdjustColumnSizing();
$("#" + dataTableid).addClass('kiketable-colsizable'); // Add kike column class
}
[/code]
This works flawlessly.