Freezing Datagrid Column Headers

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Back
Top