I have table with horizontal and vertical scroll where header is fixed. As I'm using fixed header the clone is generated for header so the resizing is not working on it. I need to resize the table columns also. Please help me...
Here is the code : http://jsfiddle.net/manishan/Hx7ak/
I didn't see anyone mentioning the DataTables.net plugin as it has some addons that work for these cases. It's totally customizable, and extendable.
For some reason my jsfiddle was showing me errors that I could not debug, but when tried in here with xammp it worked perfectly and rendered pagination, column sorting and fixed header examples.. as you can see the initialization code is quite short, but you might want to download de codebase for the imagery. I basically took your provided code elements and arrange it to apply DataTables.net jQuery plugin.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
TEST DataTables.net plugin - Fixed Header example
</title>
<script src='jquery182.js' ></script>
<script src='jquery.dataTables.js' ></script>
<script src='FixedHeader.js' ></script>
<link rel='stylesheet' href='demo_table.css'/>
<link rel='stylesheet' href='demo_page.css'/>
</head>
<body>
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display data_Table" >
<thead>
<tr>
<th style='width:47px; height:29px' >
<input name="chkSelectAll" type="checkbox" value="" id="chkSelectAll"/></th>
<th style='width:159px;font-weight:bold'>Computer <span class="actdiv"> </span></th>
<th style='width:105px;font-weight:bold'>Group <span class="actdiv"> </span></th>
<th style='width:97px;font-weight:bold'>Policy <span class="actdiv"> </span></th>
<th style='width:105px;font-weight:bold'>Domain <span class="actdiv"> </span></th>
<th style='width:126px;font-weight:bold'>Address<span class="actdiv"> </span></th>
<th style='width:127px;font-weight:bold'>Type <span class="actdiv"> </span></th>
<th style='width:109px;font-weight:bold'>Status <span class="actdiv"> </span></th>
<th style='width:181px;font-weight:bold'>Test Status <span class="actdiv"> </span></th>
<th style='width:165px;font-weight:bold'>Version <span class="actdiv"> </span></th>
<th style='width:131px;font-weight:bold'>Date <span class="actdiv"> </span></th>
<th style='width:160px;font-weight:bold'>Last Date <span class="actdiv"> </span></th>
<th style='width:173px;font-weight:bold'>Count </th>
</tr>
</thead>
<tbody>
<tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr><tr style="padding-left:10px">
<td><input name="" type="checkbox" alt="classid-1" class="chkSelectAll" style="z-index:-2"/></td>
<td class="name">DEVBUILD1</td>
<td class="groupId">test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr> </tbody>
</table>
</div>
<script>
jQuery(document).ready(function($){
var oTable = $('.data_Table').dataTable( {
// "sDom": 'RC<"clear">lfrtip'
//options: we are using
"sDom": 'Rlfrtip',
"sScrollY": "200px",
"bPaginate": true //Disable pagination false
} );
});
</script>
</body>
</html>
If you take the source code at the HTML section for that jsfiddle, and download the dependencies from that jsfiddle link (the javascript and css files, and place this html within the same directory) it should get you started in no time with it.
Although, depending on which options you might want to look into shall you decide to go for this jQuery plugin, keep in mind that it has a very active community and support and at the forums the developers should be masters with specifics.
Interesting links that can help you depending on how you would like to present your data with this plugin are:
http://www.datatables.net/release-datatables/extras/FixedHeader/two_tables.html
http://www.datatables.net/release-datatables/extras/FixedHeader/index.html
http://www.datatables.net/release-datatables/extras/FixedHeader/html_table.html
http://www.datatables.net/release-datatables/extras/ColReorder/scrolling.html
http://www.datatables.net/release-datatables/extras/ColReorder/fixedheader.html
http://www.datatables.net/release-datatables/extras/ColReorder/fixedcolumns.html
Well as you can see at http://www.datatables.net/examples/ the list of examples is quite long, but hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With