How can I freeze the header of Table?
| SitePoint Sponsor |


How can I freeze the header of Table?
[COLOR=SlateGray]
Web Developer @ VeriQual


I've a table and the data is coming from DB.
I want that when page is scrolled down, the header of the table should be visible.
[COLOR=SlateGray]
Web Developer @ VeriQual





This isnt a php problem, its a layup problem.
Your solution will depend on how you currently layup your data on the page, if your doing it correctly with <div></div> you could just put your headings in a seperate div above the div for your data, then make your data div scrollable.
A Little Knowledge Is A Very Dangerous Thing.......
That Makes Me A Lethal Weapon !!!!!!!!
Contract PHP Programming
Exactly.Your solution will depend on how you currently layup your data on the page, if your doing it correctly with <div></div> you could just put your headings in a seperate div above the div for your data, then make your data div scrollable.




Like here, for example: http://www.456bereastreet.com/lab/cssframes/


If I use this technique then there might be some alignment problem. i.e.
I have a table with data from DB. header of the table contains the the names of the columns. if cells of lower table expands due to large data, the clls in header won't expand and alignment problem can occure.
Do u have any solution for this?![]()
[COLOR=SlateGray]
Web Developer @ VeriQual





You could use CSS instead for your table layout.
You can define the width of the div cell, any overspill can wrap on a newline within the div, not breaking your layout.
A Little Knowledge Is A Very Dangerous Thing.......
That Makes Me A Lethal Weapon !!!!!!!!
Contract PHP Programming

I imagine you would have to define its position as absolute using CSS. However, what its absolute position is would have to be determined. You could calculate the distance between the top of the page and the top of the table row, but that's a hack, not real code.
Last edited by Akash Mehta; May 9, 2007 at 23:46.
Check out my SitePoint articles and blog posts!
This might help;
http://www.dhtmlgoodies.com/index.ht...t=table_widget
example here
Bookmarks