网格视图中的水平滚动 [英] horizontal scroll in grid view
本文介绍了网格视图中的水平滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个gridview列,仅在水平滚动时冻结,垂直滚动时正常行为。
I应用了以下样式,但它在水平和垂直滚动上冻结了列
td.locked
{
position:relative;
left:expression(( this .parentElement.parentElement.parentElement.parentElement.scrollTop-2)+ ' px');
}
任何人都可以帮我解决这个问题。我搜索了很多但是相同的样式随处可见。
解决方案
将网格视图放在一个Div中并设置div的类参数如下
.grid_wrapper
{
float :left;
宽度:80%;(根据您的网页设置和设计,将此 设为)
height:200px;(根据您的页面设置和设计,将此 设为)
溢出:滚动;
display:block;
}
< div class = grid_wrapper >
< asp:GridView ID = ParentGridView runat = server DataSourceID = ParentSqlDataSource
AutoGenerateColumns = False DataKeyNames = pub_id OnRowEditing = ParentGridView_OnRowEditing >
< Columns>
< asp:TemplateField HeaderText = PublisherID >
< ItemTemplate>
< asp:标签ID = pubid_lbl runat = 服务器 Text = ' <%#Eval(pub_id)%>' />
< / ItemTemplate >
< / asp:TemplateField >
< asp:TemplateField HeaderText = 名称 >
< ItemTemplate>
< asp:标签ID = name_lbl runat = 服务器 Text = ' <%#Eval(pub_name)%>' />
< / ItemTemplate >
< / asp:TemplateField >
< asp:TemplateField HeaderText = 城市 >
< ItemTemplate>
< asp:标签ID = city_lbl runat = 服务器 Text = ' <%#Eval(city)%>' />
< / ItemTemplate >
< / asp:TemplateField >
< asp:TemplateField HeaderText = 查看 >
< ItemTemplate>
< asp:按钮ID = ViewChild_Button runat = server Text = + CommandName = 编辑 />
< / ItemTemplate >
< EditItemTemplate>
< asp:按钮ID = CancelChild_Button runat = server Text = - CommandName = 取消 />
< asp:GridView ID = ChildGridView runat = server AllowPaging = true PageSize = 4 AutoGenerateColumns = false
DataSourceID = ChildSqlDataSource OnRowEditing = ChildGridView_OnRowEditing >
< Columns>
< / 列 >
< / asp:GridView >
< / EditItemTemplate >
< / asp:TemplateField >
< / 列 >
< / asp :GridView >
< / div > 跨度>
Hi,
I need a gridview column to be freezed only on horizontal scroll and a normal behaviour on vertical scroll.
I applied the below style but it freezes the column on both horizontal and vertical scroll
td.locked
{
position: relative ;
left: expression((this.parentElement.parentElement.parentElement.parentElement.scrollTop-2)+'px');
}
Can anyone pls help me out on this. I have searched a lot but the same style is posted everywhere.
解决方案
Put the grid view in one Div and set the div's class parameters as below
.grid_wrapper { float:left; width:80%;(put this as per your page settings and designs) height:200px;(put this as per your page settings and designs) overflow:scroll; display:block; }
<div class="grid_wrapper"> <asp:GridView ID="ParentGridView" runat="server" DataSourceID="ParentSqlDataSource" AutoGenerateColumns="False" DataKeyNames="pub_id" OnRowEditing="ParentGridView_OnRowEditing"> <Columns> <asp:TemplateField HeaderText="PublisherID"> <ItemTemplate> <asp:Label ID="pubid_lbl" runat="Server" Text='<%# Eval("pub_id") %>' /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Name"> <ItemTemplate> <asp:Label ID="name_lbl" runat="Server" Text='<%# Eval("pub_name") %>' /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="City"> <ItemTemplate> <asp:Label ID="city_lbl" runat="Server" Text='<%# Eval("city") %>' /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="View"> <ItemTemplate> <asp:Button ID="ViewChild_Button" runat="server" Text="+" CommandName="Edit" /> </ItemTemplate> <EditItemTemplate> <asp:Button ID="CancelChild_Button" runat="server" Text="-" CommandName="Cancel" /> <asp:GridView ID="ChildGridView" runat="server" AllowPaging="true" PageSize="4" AutoGenerateColumns="false" DataSourceID="ChildSqlDataSource" OnRowEditing="ChildGridView_OnRowEditing"> <Columns> </Columns> </asp:GridView> </EditItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div>
这篇关于网格视图中的水平滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文