Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div style="padding-right:18px"><!-- to account for the scrollbar on the other div -->
- <table id="head">
- <tr>
- <th>Col 1</th>
- <th>Col 2</th>
- </tr>
- </table>
- </div>
- <div style="height:400px; overflow-y:scroll">
- <table id="body">
- <tr>
- <td>Val 1a</td>
- <td>Val 2a</td>
- </tr>
- <tr>
- <td>Val 1b</td>
- <td>Val 2b - this cell is wide</td>
- </tr>
- </table>
- </div>
- dojo.addOnLoad(function(){
- var $bodyRow = dojo.query('#body tr')[0];
- var $headRow = dojo.query('#head tr')[0];
- dojo.forEach($bodyRow.cells, function(item, index){
- var w = item.offsetWidth;
- dojo.style($headRow.cells[index], 'width', w + "px");
- });
- });
- dojo.addOnLoad(function(){
- var $bodyRow = dojo.query('#body tr')[0];
- var $headRow = dojo.query('#head tr')[0];
- dojo.forEach($bodyRow.cells, function(item, index){
- var w = dojo.style($bodyRow.cells[index], 'width');
- dojo.style($headRow.cells[index], 'width', w + "px");
- });
- });
- th, td { width: 50%; } // get 2 equal width columns in both tables
Add Comment
Please, Sign In to add comment