Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Freezing Datagrid Column Headers

182 views
Skip to first unread message

John Walker

unread,
Jan 18, 2006, 2:40:18 PM1/18/06
to
Hi,
We have a datagrid with column headers. If the datagrid has more than say
25 rows the user needs to scroll down to be able to see the rest of the grid.
When the user does this the column headers scrolls up off the screen and it
becomes hard for the user to determine what the columns are. Is there a way
to keep the columns headers in place (only for vertical scrolling) when the
user scrolls down.

Thanks,
John

slagomite

unread,
Jan 18, 2006, 2:57:59 PM1/18/06
to
First, wrap your DataGrid in a <div>, and set the div's "overflow"
style to "scroll". This way, the user won't have to scroll the entire
page to view the contents of the grid (and this is also necessary for
the following part to work right).

Then give the DataGrid's header the following styles:

position: relative;
top: expression(this.offsetParent.scrollTop - 2);

You might have to play around with border width, padding, etc. to get
it to look right, but this should do you what you want. Hope it helps.

Luke

John Walker

unread,
Jan 18, 2006, 3:38:10 PM1/18/06
to
Luke,
Thanks I'll give it a try!
0 new messages