0

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 dark area showing is to be freezed, but there is not limit of columns

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • possible duplicate of [Scrollable HTML Table with fixed header and fixed column](http://stackoverflow.com/questions/8620205/scrollable-html-table-with-fixed-header-and-fixed-column) – Kritner May 22 '15 at 15:13
  • I've 'n' no. of rows and columns, that is the issue, anyway thanks for the direction. – Akhil Namboothiri May 22 '15 at 15:27

1 Answers1

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 
        }); 
    } 
Enrique Zavaleta
  • 2,098
  • 3
  • 21
  • 29
  • I will try for this one. thanks for the link, it showing absolutely what i want. – Akhil Namboothiri May 22 '15 at 15:24
  • @ Enrique Zavaleta: Here is a problem, the header columns are dynamically coming and 'n' no. of heading will come, so we cannot apply ID for that. also the same for the first 3 left columns. Any solution for this? – Akhil Namboothiri May 25 '15 at 09:15
  • I don't know why we cannot apply the same ID depending on the num of columns. The GridView's ID is the same no matter how many columns it has. And to freeze the first 3 columns yo don't need their ID, just with freezesize: 3 is fine and it must work – Enrique Zavaleta May 25 '15 at 13:23
  • @ Enrique , this is the issue ` ` these are Static, but in my case all are dynamic. – Akhil Namboothiri May 26 '15 at 07:45
  • You could edit your question with the issue, with more details of what is your problem, I mean, writing why is not working, what is the code you have tried and what is what you are seeing – Enrique Zavaleta May 26 '15 at 13:31