如何冻结 Asp.net gridview 的表头? 我尝试用不同的方法实现,但是没有成功。
我使用的是 ASP 2.0 和 VS 2010。
有人可以帮助我吗?
如何冻结 Asp.net gridview 的表头? 我尝试用不同的方法实现,但是没有成功。
我使用的是 ASP 2.0 和 VS 2010。
有人可以帮助我吗?
https://datatables.net/extensions/responsive/examples/column-control/fixedHeader.html
绑定GridView数据后[c#]
gridviewid.UseAccessibleHeader = true;
gridviewid.HeaderRow.TableSection = TableRowSection.TableHeader;
对于jQuery
<script>
function pageLoad(sender, args) {
//Your jquery code
$(document).ready(function () {
tableGrid();
});
function tableGrid() {
$("#<%=gridviewID.ClientID%>").dataTable().fnDestroy();
$("#<%=gridviewID.ClientID%>").dataTable({
"sPaginationType": "full_numbers",
"columnDefs": [{
"orderable": false
}],
"aaSorting": [],
info: false,
paging: true,
"oLanguage": { "sSearch": "Search: " },
mark: true,
dom: 'Blfrtip',
buttons: [], fixedHeader: true
});
}
}
</script>
ScriptManager.RegisterStartupScript(this, this.GetType(), "callheader", "tableGrid();", true);
我使用jQuery floatThead
http://mkoryak.github.io/floatThead/#intro
我不得不使用一些jQuery将第一行转换为表头才能使其正常工作。
以下是示例:
$(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">'
}
);
});