2014-09-03 48 views
0

在SO和Elesewhere中有關於凍結/固定GridView標頭的問題有多個問題。我目前正在使用單個標題GridView的插件之一。凍結gridview標頭和SUB標頭

但它不是很優雅。由於在調用jQuery函數後,標題列不與Data列對齊。

圓圈列概述顯示「未對齊」。 enter image description here

除了未對齊的問題,還需要凍結另一個GridView的標題和子標題,如下所示。

enter image description here

現在,這引起了一些擔憂。

  1. 爲子標題編寫一個新的jQuery插件。 The plug-in I am currently using refers to this post.我需要大量的知識支持來編寫一個新的。
  2. 創建兩個不同的GridView,一個用於標題,一個用於數據。並且會有對齊問題(因爲它是最早的設計)。所有這些gridviews都執行DML/CRUD操作。
  3. 是否可以爲標題編寫html代碼並隱藏GridView的標題?然而,就管理關於內容/數據的動態調整而言,這也會帶來挑戰。

鑑於這種情況和選項,我只是困惑什麼可能是成本較低(時間/努力)的方向,但與未來更新的靈活性。也很感謝編輯當前jquery函數的任何見解,以適應單個標題GridView的正確對齊。

回答

1

由於您已經在爲此使用插件,因此確保使用另一個插件應該不困難,但是這次應該將您的標題寬度與數據列對齊。確保您的定義/使用ItemStyle-Width屬性要麼boundcolumnTemplateField

鏈接到GridViewScroll Demo做這件工作完美調整列寬。從here下載插件。 請參閱我的人對SO答案herehere了類似的問題

下面是代碼

<script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script> 
<script type="text/javascript" src="gridviewScroll.min.js"></script> 
<link href="GridviewScroll.css" rel="stylesheet" /> 

function pageLoad(sender, args) { 
    gridviewScroll(); 
} 

function gridviewScroll() { 
    gridView1 = $('#GridView1').gridviewScroll({ 
     width: 915, 
     height: 449, 
     railcolor: "#F0F0F0", 
     barcolor: "#CDCDCD", 
     barhovercolor: "#606060", 
     bgcolor: "#F0F0F0", 
     freezesize: 5, 
     arrowsize: 30, 
     varrowtopimg: "../../../images/arrowvt.png", 
     varrowbottomimg: "../../../images/arrowvb.png", 
     harrowleftimg: "../../../images/arrowhl.png", 
     harrowrightimg: "../../../images/arrowhr.png", 
     headerrowcount: 1, 
     onScrollVertical: function (delta) { 
     // store the scroll offset outside of this function in a hidden field and restore if you want to maintain vertical scroll position 
     }, 
     onScrollHorizontal: function (delta) { 
      //store the scroll offset outside of this function in a hidden field and restore if you want to maintain horizontal scroll position 
     } 
    }); 
}