【问题标题】:Freeze gridview pager while scrolling vertically垂直滚动时冻结gridview寻呼机
【发布时间】:2013-05-20 18:01:47
【问题描述】:

我有一个网格视图。
我必须同时实现分页以及使页面可水平和垂直滚动。页面导航栏位于底部。

垂直滚动页面时,我想要两件事 -

  1. gridview 标题也应该被冻结。
  2. gridview 寻呼机也应该被冻结。

我的意思是他们不应该随着数据滚动。
只有行应该滚动。

我已经实现了 -
1. 使用 CSS 修复标题
2. 使用 CSS 水平滚动
3.使用CSS垂直滚动

我不能
1. 修复寻呼机。

我的代码:

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<style type="text/css">
    div#gvResultStyle
    {
        width: 500px;
        height: 350px;
        overflow: scroll;
        position: relative;
    }

    div#gvResultStyle th
    {
        background-color: Navy;
        color: White;
        top: expression(document.getElementById("gvResultStyle").scrollTop-2);
        left: expression(parentNode.scrollLeft);
        position: relative;
        z-index: 20;
    }

    .gvPager
    {
        left: 0px;
        width: 400px;
        border-right-style: solid;
        position: absolute;
        height: 10px;
        text-align: left;
        border-right-color: Navy;
    }
</style>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
    Welcome to ASP.NET!
</h2>
<p>
    To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">
        www.asp.net</a>.
</p>
<p>
    You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
        title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
</p>
<div id="gvResultStyle">
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID"
    DataSourceID="SqlDataSource1" AllowPaging="true" PageSize="20" CssClass="gvResultStyle">
    <PagerSettings Position="Bottom" />
    <PagerStyle CssClass="gvPager" />
    <Columns>
        <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
            ReadOnly="True" SortExpression="ProductID" />
        <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
        <asp:BoundField DataField="SupplierID" HeaderText="SupplierID" SortExpression="SupplierID" />
        <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" />
        <asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit" />
        <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
        <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
        <asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
        <asp:BoundField DataField="ReorderLevel" HeaderText="ReorderLevel" SortExpression="ReorderLevel" />
        <asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" />
        <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
    </Columns>
</asp:GridView>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT * FROM [Alphabetical list of products]"></asp:SqlDataSource>
<br />

【问题讨论】:

    标签: asp.net css gridview paging scrollable


    【解决方案1】:

    我写的jQuery插件可以固定标题和冻结列,可以应用于GridView。 看图:

    它还支持寻呼机:

    演示:Pager Support

    【讨论】:

    • 查看了您的网站。但是这个文件gridviewScroll.min.js在哪里?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-01
    • 2020-11-14
    • 1970-01-01
    • 1970-01-01
    • 2018-11-09
    • 2015-10-10
    • 2019-12-03
    相关资源
    最近更新 更多