Column widths changing when sorting
Column widths changing when sorting
eyre.michael
Posts: 21Questions: 0Answers: 0
Hello,
I have a strange issue with an app that I am building using Datatables. This application is using JAVA and Struts2, but I do not think that that really has an issue with it, but you never know.
The definition of the table is within a that has a style of width:100%.
Here is the code for defining the table:
[code]
_logSheetTable = $('#logsheet-table').dataTable({
sScrollY: "250px",
bPaginate: false,
bAutoWidth: true,
aaData: [["LeRNum1","Title1","Volume1","Section1","Franchise1","ProductName1","ProductCode1"],["LeRNum2","Title2","Volume2","Section2","Franchise2","ProductName2","ProductCode2"]],
bSort: true,
aoColumns: [
null,
null,
null,
null,
null,
null,
null
]
});
[/code]
The problem that I am having is that when the div width is set to 100% and I click on a column to sort it, the column widths change. If I set the div width to 900px, the column widths do not change. I have tried this on Chrome and Safari, but not on IE yet. I will try it on IE later today.
What can I do to make this not happen? I have use datatables on other application, and this is the first one that I am seeing this problem on.
Thanks
Mike
I have a strange issue with an app that I am building using Datatables. This application is using JAVA and Struts2, but I do not think that that really has an issue with it, but you never know.
The definition of the table is within a that has a style of width:100%.
Here is the code for defining the table:
[code]
_logSheetTable = $('#logsheet-table').dataTable({
sScrollY: "250px",
bPaginate: false,
bAutoWidth: true,
aaData: [["LeRNum1","Title1","Volume1","Section1","Franchise1","ProductName1","ProductCode1"],["LeRNum2","Title2","Volume2","Section2","Franchise2","ProductName2","ProductCode2"]],
bSort: true,
aoColumns: [
null,
null,
null,
null,
null,
null,
null
]
});
[/code]
The problem that I am having is that when the div width is set to 100% and I click on a column to sort it, the column widths change. If I set the div width to 900px, the column widths do not change. I have tried this on Chrome and Safari, but not on IE yet. I will try it on IE later today.
What can I do to make this not happen? I have use datatables on other application, and this is the first one that I am seeing this problem on.
Thanks
Mike
This discussion has been closed.
Replies
Thanks
Mike
We ran into the same issue when using Datatables 1.8.1 and our solution was to upgrade to Datatables 1.9.2 in which the issue does not exist.
This is only happening on tables that are wide enough to have a horizontal scroll bar. The entire table width is being sized dynamically based on sorted or filtered result, but the headers are not being resized. Is there a way to set table width so it doesn't change and is based on what's shown on original page load. Either that, or resize the headers when the table is resized?
Allan
The odd part is that I realize the column headers are resizing, just not as much as the table content. The issue is hardly noticeable on high-res screens, but on low-res monitors the difference is so severe that content shifts by as much as 2 columns. The content for column 12 is under heading column 10, for example.
Update:
Allan pointed out setting "sScrollXInner": "100%" was the culprit. Removed that and columns resize correctly. Thank you!