How to freeze header and first column of a Table data grid listing with unlimited rows and columns?

感情迁移 提交于 2019-12-11 20:17:03

问题


I have an asp.NET grid listing with unlimited columns and rows. This is showing as a result of search (some kind of work history data). Depending on the search criteria, the no. of columns and no. of rows will increase.

I need to fix/freeze first row (header portion) and 3 columns on the left (that 3 columns need to show all the time and rest of the contents can scroll).

In the code page this much content is visible:

<div style="height:500px; overflow:auto">
<asp:GridView ID="someid" runat="server">
</asp:GridView>    
</div>

The header columns are dynamically coming and 'n' no. of heading will come (like April 2016, May 1026 and so on..), so cannot apply 'id' for each heading. also the same for the first 3 left columns. Any solution for this?


回答1:


Take a look at this gridviewscroll pluggin, here you find a jquery pluggin to accomplish what you want

and after you add the proper css and js files the code you should use is this:

$(document).ready(function () { 
        gridviewScroll(); 
    }); 

    function gridviewScroll() { 
        $('#<%=someid.ClientID%>').gridviewScroll({ 
            width: 660,   //change this two values by
            height: 200,  //your real width and height
            freezesize: 3 
        }); 
    } 


来源:https://stackoverflow.com/questions/30400019/how-to-freeze-header-and-first-column-of-a-table-data-grid-listing-with-unlimite

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