How Can We Have A SCROLLABLE GridView With Fixed Header?

孤者浪人 提交于 2019-12-06 11:19:01

two tables, one for header and one for content. only problem is that u need to set specific widths for each column.

<style>
    .tbl th { border: 1px solid black; background:#DDD; }
    .tbl td { border: 1px solid black; border-top:none }
    .scroll { height:80px; overflow-y:auto }
</style>

<table class="tbl">
    <colgroup>
        <col style="width:100px" />
        <col style="width:150px" />
    </colgroup>
    <tr>
        <th>header1</th>
        <th>header2</th>
    </tr>
 </table>

<div class="scroll">
    <table class="tbl">
        <colgroup>
            <!-- same as before -->
            <col style="width:100px" />
            <col style="width:150px" />
        </colgroup>
        <tr><td>....</td><td>...</td></tr>
        <tr><td>....</td><td>...</td></tr>
        <tr><td>....</td><td>...</td></tr>
        <tr><td>....</td><td>...</td></tr>
        <tr><td>....</td><td>...</td></tr>
        <tr><td>....</td><td>...</td></tr>
        <tr><td>....</td><td>...</td></tr>
        <tr><td>....</td><td>...</td></tr>
        <tr><td>....</td><td>...</td></tr>
    </table>
<div>
​

This blog post might help you:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=255&AspxAutoDetectCookieSupport=1

He has found a way to create fixed gridview headers and footers using a bit of jQuery. I haven't tried this myself, but judging by the comments, it works for many people.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!