2012-03-10 102 views
6

如何冻结Asp.net gridview标题?我试图以不同的方式做到这一点,但无法做到。冻结标题,滚动GridView

我使用ASP 2.0和VS 2010

任何一个能帮助我吗?

+0

下面的链接显示了一种方法来实现这一[冻结GridView的列和集管在ASP.Net CSS](http://www.vbknowledgebase.com/?Id=91&Desc= Freeze-GridView-Columns-and-Headers-in-ASP.Net-CSS)我为此问题添加了2个链接,您可以尝试。对我来说,我建议的第一个工作,所以很可能你错过了一些东西。然而,其他两种解决方案也在工作,所以你可以试用它们。 [使用固定标题的Gridview](http://www.codeproject.com/Articles/250669/Gridview-with-Fixed-Header)和[通过创建客户端扩展程序来冻结ASP.NET GridView标题](http:// weblogs .asp.net/d – 2012-03-10 19:08:20

+0

感谢Aristotelis。但我已经尝试过,这对我没有任何作用。是否有任何方法冻结标题编程方式。 – Indra 2012-03-11 03:57:34

+0

我试过类似的东西... http://stackoverflow.com/questions/28351955/how从列表和一个asp-net-generated-gridview-tabl,但宽度不匹配 – SearchForKnowledge 2015-02-05 21:08:14

回答

0

使用jQuery floatThead

http://mkoryak.github.io/floatThead/#intro

我不得不使用位的jQuery转换到第一行的THEAD为它工作。

例如下面:

$(document).ready(function() { 
    var $theadCols = $("#ContentPlaceHolder1_grdCashflow tr:first-child"), 
     $table = $("#ContentPlaceHolder1_grdCashflow"); 

    // create thead and append <th> columns 
    $table.prepend("<thead/>"); 
    $table.find("thead").append($theadCols); 

    // init stickyHeader 
    $table.floatThead(); 

    //$table = $("#ContentPlaceHolder1_grdCashflow"); 
    $table.dataTable(
    { 
     "paging": false, 
     "ordering": false, 
     "dom":'<"top"fi>rt<"bottom"><"clear">' 
    } 
    ); 
});