Table resize on windows resize
Table resize on windows resize
In the:
$(document).ready(function()
I have:
var calcDataTableHeight = function() {
return $(window).height() - document.getElementById('tableSearch').offsetHeight - document.getElementById('tableButtons').offsetHeight - 100;
};
var calcDataTableWidth = function() {
return $(window).width() - 100;
};
// for ie, only resize if no resize activity for a second
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
// resize datatable
$(window).resize(function () {
return;
delay(function(){
var oSettings = oTable.fnSettings();
oSettings.oScroll.sX = calcDataTableWidth();
oSettings.oScroll.sY = calcDataTableHeight();
oTable.fnDraw(true);
}, 1000);
});
My table is:
oTable = $('#testData').dataTable({
"sPaginationType": "full_numbers",
"bPaginate": true,
"bFilter": false,
"bSort": false,
"bAutoWidth": true,
"sScrollX": calcDataTableWidth(),
"sScrollY": calcDataTableHeight(),
"iDisplayLength": 50,
"bScrollCollapse": false,
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"bDeferRender": true,
"sAjaxSource": "/get_data" + params
});
The table resizes when I set "bScrollCollapse": true, but then on initial load window.resize keeps getting called over and over again. This happens, I think, because the table is empty.
Setting "bScrollCollapse": false, on the other hand fails to resize the table after oTable.fnDraw(true);
Can anyone offer a solution.
Thanks,
Kevin.
$(document).ready(function()
I have:
var calcDataTableHeight = function() {
return $(window).height() - document.getElementById('tableSearch').offsetHeight - document.getElementById('tableButtons').offsetHeight - 100;
};
var calcDataTableWidth = function() {
return $(window).width() - 100;
};
// for ie, only resize if no resize activity for a second
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
// resize datatable
$(window).resize(function () {
return;
delay(function(){
var oSettings = oTable.fnSettings();
oSettings.oScroll.sX = calcDataTableWidth();
oSettings.oScroll.sY = calcDataTableHeight();
oTable.fnDraw(true);
}, 1000);
});
My table is:
oTable = $('#testData').dataTable({
"sPaginationType": "full_numbers",
"bPaginate": true,
"bFilter": false,
"bSort": false,
"bAutoWidth": true,
"sScrollX": calcDataTableWidth(),
"sScrollY": calcDataTableHeight(),
"iDisplayLength": 50,
"bScrollCollapse": false,
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"bDeferRender": true,
"sAjaxSource": "/get_data" + params
});
The table resizes when I set "bScrollCollapse": true, but then on initial load window.resize keeps getting called over and over again. This happens, I think, because the table is empty.
Setting "bScrollCollapse": false, on the other hand fails to resize the table after oTable.fnDraw(true);
Can anyone offer a solution.
Thanks,
Kevin.
This discussion has been closed.