“Floating” Gridview Header

后端 未结 3 1705
花落未央
花落未央 2020-12-22 09:34

Is there a way in ASP.NET to have a \"floating\" header, much like a header you would see in an Excel sheet that follows you down the page as you scroll?

Or alternat

3条回答
  •  清酒与你
    2020-12-22 10:05

    A pure css based solution can break in some browsers. For that you must make use of some javascript too.

    The condensed version of the most favored approach is to clone the original table. Put both tables (hereafter referred to as table1 and table2) inside div containers. The div containers will overlap a bit, and most importantly clip stuff we do not need to show. And the two divs will be stacked (siblings). The first div will contain table1 and its viewable area will be resized to only show the table1 header row. Its scrollbars will also be hidden. table2 will be placed inside the 2nd div with sufficient -ve margin so that its header is not visible to the user. Further more we have to take care of events incase we want to scroll horizontally.

    Ps: Will show some code once I have time...

提交回复
热议问题