当前位置:编程学习 > asp >>

ASP.NET 固定标题列与栏位

 

                 客户提这个要求很久了,最近才时间弄,但是看到百度中要没有很多详细的代码。可能谷歌到香港可以看到,所以这片文章算原创也算转载。

       这个网址基本上您就懂了。 我会放一个已经下载好的 DOME 也是官网的,在CSDN上。特此说明这个是官网的,我只是转载下载。谢谢。

废话不多说直接贴代码。

 

                     APSX 页面代码: 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" />

//以上的文件都可以直接到网上下载的
 
    <script type="text/javascript">

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

        function gridviewScroll() {

//  因为我的GRIDVIEW 要放在一个DIV中所以要获得对应的高度和宽度,一般直接数字设置就好了

            var gridWidth = $("#divservic").width();
            var gridHeight = $("#divservic").height();

            var headerHeight = $("#divHeader").height();

            gridHeight = gridHeight - headerHeight;
 
            $('#<%=GridView2.ClientID%>').gridviewScroll({
            width: gridWidth,//宽度 一定不能用100%  可直接写死
            height: gridHeight,//高度  可以直接写死
            freezesize:4//控制头几列不动
            });
        }

 

<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"  />>-------------------------------------------------------------这里的样式要添加
                                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                                <PagerStyle CssClass="GridviewScrollPager"  />-------------------------------------------------------------这里的样式要添加
                                <SelectedRowStyle BackColor="#C5BBAF"  />
                                <HeaderStyle CssClass="GridviewScrollHeader" />-------------------------------------------------------------这里的样式要添加
                                <EditRowStyle BackColor="#7C6F57" />
                                <AlternatingRowStyle BackColor="White" BorderColor="#D1DDAA" />
                                <Columns>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="ckbitem" runat="server" />
补充:Web开发 , ASP.Net ,

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,