More on resizing html tables
Hi friends,
We have already discussed, how to resize html tables. This script is very nice but the common requirement is to fix the headers i.e. there should be only data scroll and fixed headers.
I have achieved this with help of another script available here.
In short, just put following style tag in your script,
<style>
/* This style tag contains classes for fixed headers */
body{
overflow:auto;
}
div.tableContainer {
position:absolute;
top:0;
left:0;
width:100%; /* table width will be 99% of this*/
height:100%; /* must be greater than tbody*/
overflow:auto;
}
table>tbody { /* only for mozilla - child selector syntax which IE6 and older do not support*/
overflow: auto;
height: 550px;
overflow-x: hidden;
}
thead tr{
position:relative;
top: expression(offsetParent.scrollTop); /*IE5+ only*/
}
</style>
Put your 'tablekit' table inside 'div'. My table looks like following,
<div class="tableContainer">
<table border="0" cellpadding="4" cellspacing="0" align="center" width="100%" class="tdata sortable resizable" id="table_top">
................
</table>
</div>
MOST IMPORTANT POINT, 'tablekit' table border MUST be zero. With a border, the headers are steady but keeps shaking when you scroll data ( test yourself :) ) You can always get the borders with style sheet, isn't it ? For the newbies, you can put a class like,
td.frame_data{
border-right:1px solid #f0f0ef;
border-bottom:1px solid #f0f0ef;
}
Happy coding :)
cya,
Sandeep
We have already discussed, how to resize html tables. This script is very nice but the common requirement is to fix the headers i.e. there should be only data scroll and fixed headers.
I have achieved this with help of another script available here.
In short, just put following style tag in your script,
<style>
/* This style tag contains classes for fixed headers */
body{
overflow:auto;
}
div.tableContainer {
position:absolute;
top:0;
left:0;
width:100%; /* table width will be 99% of this*/
height:100%; /* must be greater than tbody*/
overflow:auto;
}
table>tbody { /* only for mozilla - child selector syntax which IE6 and older do not support*/
overflow: auto;
height: 550px;
overflow-x: hidden;
}
thead tr{
position:relative;
top: expression(offsetParent.scrollTop); /*IE5+ only*/
}
</style>
Put your 'tablekit' table inside 'div'. My table looks like following,
<div class="tableContainer">
<table border="0" cellpadding="4" cellspacing="0" align="center" width="100%" class="tdata sortable resizable" id="table_top">
................
</table>
</div>
MOST IMPORTANT POINT, 'tablekit' table border MUST be zero. With a border, the headers are steady but keeps shaking when you scroll data ( test yourself :) ) You can always get the borders with style sheet, isn't it ? For the newbies, you can put a class like,
td.frame_data{
border-right:1px solid #f0f0ef;
border-bottom:1px solid #f0f0ef;
}
Happy coding :)
cya,
Sandeep
Comments