Row Headers Resize
Row Headers Resize
housleyp
Posts: 5Questions: 0Answers: 0
I have just noticed that when I re-size my browser, my table will re-size dynamically but the headers never re-size. I just download version 1.8 in hopes of fixing this issue but it still happens. The following is my data table def:
[code]$('#avail_table').dataTable({
'bAutoWidth': true,
'bFilter': false,
'bInfo': false,
'bJQueryUI': true,
'bLengthChange':true,
'bPaginate': true,
'bProcess': true,
'bScrollInfinite': false,
'bSort':true,
'bSortClasses':true,
'bStateSave':false,
'aaSorting': [[0, 'desc']],
'sDom': 'rt<\'F\'lip><\'clear\'>',
'sPaginationType': 'two_button',
'sScrollX': '100%',
'sScrollXInner': '100%',
'iDisplayLength': 20,
'aLengthMenu': [[20, 40, 60, 80, 100], [20, 40, 60, 80, 100]],
'aoColumnDefs': [
{'bSortable': false, 'aTargets': [1,2,3] }
],
'fnRowCallback': function(row, data, index) { // Function will be called for every row displayed \\
$(row).unbind().bind('mouseover', function(event) {
$.each($(this).find('td'), function() {
$(this).css('background', '#9199FF');
});
}).bind('mouseout', function(event) {
$.each($(this).find('td'), function() {
$(this).css('background', '');
});
});
// Add context menu to each row \\
$(row).contextMenu({ menu: 'cm_avail_ls-0001'}, function(action, element, index) {
..... Other stuff here ......
});
return (row);
}
});[/code]
Am I missing something like an option?
[code]$('#avail_table').dataTable({
'bAutoWidth': true,
'bFilter': false,
'bInfo': false,
'bJQueryUI': true,
'bLengthChange':true,
'bPaginate': true,
'bProcess': true,
'bScrollInfinite': false,
'bSort':true,
'bSortClasses':true,
'bStateSave':false,
'aaSorting': [[0, 'desc']],
'sDom': 'rt<\'F\'lip><\'clear\'>',
'sPaginationType': 'two_button',
'sScrollX': '100%',
'sScrollXInner': '100%',
'iDisplayLength': 20,
'aLengthMenu': [[20, 40, 60, 80, 100], [20, 40, 60, 80, 100]],
'aoColumnDefs': [
{'bSortable': false, 'aTargets': [1,2,3] }
],
'fnRowCallback': function(row, data, index) { // Function will be called for every row displayed \\
$(row).unbind().bind('mouseover', function(event) {
$.each($(this).find('td'), function() {
$(this).css('background', '#9199FF');
});
}).bind('mouseout', function(event) {
$.each($(this).find('td'), function() {
$(this).css('background', '');
});
});
// Add context menu to each row \\
$(row).contextMenu({ menu: 'cm_avail_ls-0001'}, function(action, element, index) {
..... Other stuff here ......
});
return (row);
}
});[/code]
Am I missing something like an option?
This discussion has been closed.
Replies
Hopefully this bug can get fixed.
So there is an API method to address this: http://datatables.net/api#fnAdjustColumnSizing . Just call fnAdjustColumnSizing whenever you want the column sizes to be recalculated and aligned. That could be in your resize callback for example.
Allan
$(window).resize( function () {
oTable.fnAdjustColumnSizing();
} );
[/code]
assuming oTable is the reference to your DataTable instance.
Allan
[code]
queueTable = $('#pendDataTable').dataTable( {
"sPaginationType": "full_numbers",
"bServerSide": true,
"bProcessing": true,
"aoColumns": [ null,null,null, null, null, null, null, null, {"sType": "currency"}, { "sType": "currency"}, { "sType": "currency"} ,null, {fnRender:fnCreateSelect},{fnRender:fnCreateCheckbox},{fnRender:fnCreateCheckboxForBillRemove},{ "bVisible": false },{ "bVisible": false },{ "bVisible": false },{ "bVisible": false },{ "bVisible": false },{ "bVisible": false },{ "bVisible": false },{ "bVisible": false },{ "bVisible": false },{ "bVisible": false },{ "bVisible": false },{ "bVisible": false }],
"sAjaxSource": "<%=request.getContextPath()%>/pend",
"type": "POST",
"bFilter": false,
"fnInitComplete": function() {
this.fnAdjustColumnSizing(true);
},
[/code]
[code]
$(window).resize( function () {
queueTable.fnAdjustColumnSizing();
} );
[/code]
when my browser is full screen the row width and header width are alright.
But when i resize my browser, the horizontal scroll appears for the rows but column headers remain fixed and doesnt resize along with the rows.
I am using the latest version 1.8.
Please help
-medSwa
Allan
In this situation, the table columns are resizing, shouldn't the headers resize automatically as well? Maybe I'm getting my terminology crossed, but this seems like a "bug" because I can't think of any reason to let the column widths get out of sync with the column heads.
Anyway, Datatables rocks!
Thank you!!!
first of, great work on grid, it's awesome.
I agree with shanimal, that this behaviour is seems more like a bug, or lacking feature if you will. I think you will agree that calling fnAdjustColumnSizing() on every resize event might be quite expensive operation. How about including cheaper workaround of this functionality in your future builds?!
Allan