网格视图固定头 [英] Grid view fixed header

查看:115
本文介绍了网格视图固定头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要修复的网格视图的标题。我试过的JScript文件,

I need to fix header of the grid view. I tried jscript file ,

        <div class="Container"  style="width: 816px; height: 319px;">
                                                        <asp:GridView 
                                                        ID="GrdViewMyTasks" runat="server" AllowSorting="True" 
                                                        AutoGenerateColumns="False" BackColor="White" BorderColor="#0061C1" 
                                                        BorderStyle="None" CaptionAlign="Bottom" EmptyDataText="No Records Found" 
                                                        Font-Names="Verdana" Font-Size="X-Small" ForeColor="#0061C1"  
                                                        OnRowDataBound="GrdViewMyTasks_RowDataBound" width="99%" Height="247px"
                                                        onselectedindexchanged="GrdViewMyTasks_SelectedIndexChanged" ShowFooter="True" 
                                                        ShowHeaderWhenEmpty="True" >
                                                        <Columns>
                                                        <asp:BoundField DataField="TaskID" HeaderText="SL No" >
                                                                <FooterStyle BackColor="#0061C1" />
                                                                <HeaderStyle BackColor="#0061C1" HorizontalAlign="Center" 
                                                                VerticalAlign="Middle"  />
                                                              <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                             </asp:BoundField>
                                                             <asp:TemplateField HeaderText="Task Name">
                                                             <ItemTemplate>
                                                                <asp:Label ID="TaskName" runat="server" 
                                                                    Font-Names="Verdana" Font-Size="X-Small" Height="24px" 
                                                                    Text='<%# Eval("TaskName")%>' Width="70px"></asp:Label>
                                                            </ItemTemplate>
                                                            <FooterStyle BackColor="#0061C1" />
                                                            <HeaderStyle BackColor="#0061C1" ForeColor="White"   />
                                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Due Date">
                                                            <ItemTemplate>
                                                            <asp:Label 
                                                                    ID="DueDate" runat="server" DataFormatString="{0:dd/MM/yyyy}" 
                                                                    Font-Names="Verdana" Font-Size="X-Small" Height="20px" 
                                                                    Text='<%# Eval("DueDate","{0:dd/MM/yyyy}")%>' Width="70px"></asp:Label>
                                                            </ItemTemplate>
                                                            <FooterStyle BackColor="#0061C1" />
                                                            <HeaderStyle BackColor="#0061C1" ForeColor="White"   />
                                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Description">
                                                            <ItemTemplate>
                                                            <asp:Label 
                                                                    ID="Description" runat="server" Font-Names="Verdana" Font-Size="X-Small" 
                                                                    Height="20px" Text='<%# Eval("Description")%>' Width="90px"></asp:Label>
                                                            </ItemTemplate>
                                                            <FooterStyle BackColor="#0061C1" />
                                                            <HeaderStyle BackColor="#0061C1" ForeColor="White"  />
                                                            <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Assign By">
                                                            <ItemTemplate>
                                                            <asp:Label 
                                                                    ID="AssignBy" runat="server" Font-Names="Verdana" Font-Size="X-Small" 
                                                                    Height="20px" Text='<%# Eval("AssignBy")%>' Width="80px"></asp:Label>
                                                            </ItemTemplate>
                                                            <FooterStyle BackColor="#0061C1" />
                                                            <HeaderStyle BackColor="#0061C1" ForeColor="White"   />
                                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Status">
                                                            <ItemTemplate>
                                                            <asp:Label 
                                                                    ID="Status" runat="server" Font-Names="Verdana" Font-Size="X-Small" 
                                                                    Height="20px" Text='<%# Eval("Status")%>' Width="60px"></asp:Label>
                                                            </ItemTemplate>
                                                            <FooterStyle BackColor="#0061C1" />
                                                            <HeaderStyle BackColor="#0061C1" ForeColor="White"  />
                                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="% Complete">
                                                            <ItemTemplate>
                                                            <asp:Label 
                                                                    ID="PercentageComplete" runat="server" Font-Names="Verdana" Font-Size="X-Small" 
                                                                    Height="20px" Text='<%# Eval("PercentageComplete")%>' Width="70px"></asp:Label>
                                                            </ItemTemplate>
                                                            <FooterStyle BackColor="#0061C1" />
                                                            <HeaderStyle BackColor="#0061C1" ForeColor="White"  />
                                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="View Details">
                                                            <ItemTemplate>
                                                            <asp:HyperLink 
                                                                    ID="ViewDetails" runat="server" DataNavigateUrlFields="TaskID" 
                                                                    DataNavigateUrlFormatString="Reports.aspx?TaskID={0}" Font-Names="Verdana" 
                                                                    Font-Size="X-Small" ForeColor="#0061C1" Height="24px" Width="70px"
                                                                    NavigateUrl="Reports.aspx" Text="ViewDetails" >View</asp:HyperLink>
                                                            </ItemTemplate>
                                                            <FooterStyle BackColor="#0061C1" />
                                                            <HeaderStyle BackColor="#0061C1" ForeColor="White"   />
                                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                            </asp:TemplateField>
                                                        </Columns>
                                                    </asp:GridView>
                                                    </div>

                  <style type="text/css">

                  .Container
                    {
                        overflow: auto;
                     }
      <script src="jquery-1.4.1.min.js" type="text/javascript"></script>
      <script src="ScrollableGrid.js" type="text/javascript"></script>

       <script type="text/javascript" language="javascript">
          $(document).ready(function () {
           $('#<%=GrdViewMyTasks.ClientID %>').Scrollable();
           }
           )
               </script>

头被frixed但ð网格视图宽度缩短和头大小已增加到..它dsnt得到合适的D div标签..我已经把我的网格视图code和jQuery文件

header gets frixed but d grid view width has shortened and header size has been increased.. it dsnt gets fit with d div tag .. i have placed my grid view code and jquery file

推荐答案

您可以尝试在 JS 文件中像

<script type="text/javascript" language="javascript">
$(document).ready(function() 
{
$('#<%=GridViewName.ClientID %>').Scrollable();
}
)
</script>

勾选此 jQuery的固定头滚动的GridView

您会得到 ScrollableGrid.js 文件rel=\"nofollow\"> jQuery的一部开拓创新的网站

You will get ScrollableGrid.js file from Jquery orignal website.

希望它为你工作。

这篇关于网格视图固定头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆