ASP. NET fixed header column and column specific implementation
- 2020-06-15 08:00:48
- OfStack
APSX page code: JS
<script src="../Js/jquery-1.8.3.min.js" type="text/javascript"></script> -
<script src="../Js/jquery-ui-1.10.3.custom.js" type="text/javascript"></script>
<script src="../Js/gridviewScroll.min.js" type="text/javascript"></script>
<link href="../CSS/GridviewScroll.css" rel="stylesheet" type="text/css" />
// The above files can be downloaded directly to the Internet
<script type="text/javascript">
$(document).ready(function() {
gridviewScroll();
});
function gridviewScroll() {
// Because of my GRIDVIEW Should be placed 1 a DIV So to get the height and width, 1 General direct number setting is good
var gridWidth = $("#divservic").width();
var gridHeight = $("#divservic").height();
var headerHeight = $("#divHeader").height();
gridHeight = gridHeight - headerHeight;
$('#<%=GridView2.ClientID%>').gridviewScroll({
width: gridWidth,// The width of the 1 Can not be used to set 100% Can write dead directly
height: gridHeight,// highly You can just write it dead
freezesize:4// Keep the first columns still
});
}
<div id="divservic" style="width: 100%;margin-bottom: 2px; height:220px;">
<asp:GridView ID="GridView2" runat="server" CellPadding="4" ForeColor="#333333" Width="100%"
BorderColor="#D1DDAA" AllowPaging="True" DataKeyNames="InstallationID"
OnPageIndexChanging="GridView2_PageIndexChanging"
onrowdatabound="GridView2_RowDataBound"
onrowdeleting="GridView2_RowDeleting" AutoGenerateColumns="False"
AllowSorting="True" onsorting="GridView2_Sorting">
<RowStyle CssClass="GridviewScrollItem" />>------------------------------------------------------------- I'm going to add styles here
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle CssClass="GridviewScrollPager" />------------------------------------------------------------- I'm going to add styles here
<SelectedRowStyle BackColor="#C5BBAF" />
<HeaderStyle CssClass="GridviewScrollHeader" />------------------------------------------------------------- I'm going to add styles here
<EditRowStyle BackColor="#7C6F57" />
<AlternatingRowStyle BackColor="White" BorderColor="#D1DDAA" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="ckbitem" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="InstallationID" HeaderText="InstallationID"
SortExpression="InstallationID" />
<asp:BoundField DataField="Completed" HeaderText="Completed" />
<asp:BoundField DataField="Tid" HeaderText="Tid" />
<asp:BoundField DataField="Mid" HeaderText="Mid" />
<asp:BoundField DataField="Bank" HeaderText="Bank" />
<asp:BoundField DataField="Model" HeaderText="Model" />
<asp:BoundField DataField="Barcode" HeaderText="Barcode" />
<asp:BoundField DataField="DateReq" HeaderText="DateReq"
SortExpression="DateReq" />
</Columns>
</asp:GridView>
</div>