Freezing Datagrid Column Headers

Discussion in 'ASP .Net' started by =?Utf-8?B?Sm9obiBXYWxrZXI=?=, Jan 18, 2006.

  1. 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
    =?Utf-8?B?Sm9obiBXYWxrZXI=?=, Jan 18, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?Sm9obiBXYWxrZXI=?=

    slagomite Guest

    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
    slagomite, Jan 18, 2006
    #2
    1. Advertising

  3. Luke,
    Thanks I'll give it a try!

    "slagomite" wrote:

    > 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
    >
    >
    =?Utf-8?B?Sm9obiBXYWxrZXI=?=, Jan 18, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gh0st54
    Replies:
    0
    Views:
    389
    gh0st54
    Jan 30, 2005
  2. gh0st54
    Replies:
    2
    Views:
    5,469
    Eliyahu Goldin
    Jan 31, 2005
  3. Krishna
    Replies:
    0
    Views:
    520
    Krishna
    Jul 13, 2006
  4. James
    Replies:
    0
    Views:
    503
    James
    Sep 21, 2006
  5. Nathan Baulch
    Replies:
    1
    Views:
    139
    Nathan Baulch
    Sep 19, 2003
Loading...

Share This Page