Resizing columns after making hidden columns visible
Resizing columns after making hidden columns visible
bryceray1121
Posts: 65Questions: 0Answers: 0
I've read through quite a few threads in attempt to get this working, however I've been unable to find a solution to my particular problem.
I have about 14 tables on a page and I wanted some columns to be hidden by default. TO accomplish this I used aoColumnDefs like this:
[code]
//Logic to load all tables into html page
//then adjust all the tables at once using renderDataTables below.
var oTable = renderDataTables(id)
function renderDataTable(id){
var oTable = jQuery(id).dataTable( {
"sScrollY": "200px",
"bScrollCollapse":true,
"sDom": 'rt<"bottom"flp>',
"bPaginate": false,
"bStateSave": false,
"aoColumnDefs": [
{"bSearchable": false, "bSortable": false, "aTargets": "dataTable-exclude"},
{"bVisible":false,"aTargets":"dataTables_notVisible"}
]
} );
return oTable;
}
[/code]
I then have a button in my table that when clicked calls this function:
[code]
function fnShowHide( iCols)
{
for(var i=0;i
I have about 14 tables on a page and I wanted some columns to be hidden by default. TO accomplish this I used aoColumnDefs like this:
[code]
//Logic to load all tables into html page
//then adjust all the tables at once using renderDataTables below.
var oTable = renderDataTables(id)
function renderDataTable(id){
var oTable = jQuery(id).dataTable( {
"sScrollY": "200px",
"bScrollCollapse":true,
"sDom": 'rt<"bottom"flp>',
"bPaginate": false,
"bStateSave": false,
"aoColumnDefs": [
{"bSearchable": false, "bSortable": false, "aTargets": "dataTable-exclude"},
{"bVisible":false,"aTargets":"dataTables_notVisible"}
]
} );
return oTable;
}
[/code]
I then have a button in my table that when clicked calls this function:
[code]
function fnShowHide( iCols)
{
for(var i=0;i
This discussion has been closed.
Replies
Does that do the trick?
Allan
"DataTables warning (table id = 'problems-table'): The table cannot fit into the current element which will cause column misalignment. It is suggested that you enable x-scrolling or increase the width the table has in which to be drawn"
I'm assuming their is no way around this problem short of reducing the number of columns or increasing the width of the table. However, while I was testing I noticed that if a page loads and the browser is not maximized (lets just say at 1/2 width) and then I maximize the headers do not expand to the full width of the newly expanded table and the background shows through.
The error messages also suggest I enable x-scrolling. However, when I do this only the scrollbody scrolls. The headers remain in place which makes it difficult to understand what data you are actually looking at.
Allan
[code]
function renderDataTable(id){
var oTable2 = jQuery(id).dataTable( {
"sScrollY": "200px",
"sScrollX": "100%", /* Required for viewing tables with lots of columns at low resolution - otherwise columns are mis-aligned */
"bScrollCollapse":true,
"sDom": 'rt<"bottom"flp>',
"bPaginate": false,
"bStateSave": false,
"aoColumnDefs": [
{"bSearchable": false, "bSortable": false, "aTargets": "dataTable-exclude"},
{"bVisible":false,"aTargets":["dataTables_notVisible"]}
]
} );
[/code]
Allan
http://www.flickr.com/photos/26503296@N04/5096839782/
http://www.flickr.com/photos/26503296@N04/5096839790/
This is the html (with some mixed in javascript). The datatables are applied to the table within the form. The top table is just the header.
[code] ''+
''+
''+
''+
''+
''+
''+this.longTitle+''+
''+
''+
''+
''+
'Details'+
' Print'+
''+
''+
''+
''+
''+
''+
''+
''+
''+
''+
this.getDetailsHeader()+
''+
''+
''+
sections["details"]+
''+
''+
''+
'';[/code]
I appreciate your help.