How to include a header on each page when printing a DataGrid
来源:互联网 发布:psp网络联机游戏 编辑:程序博客网 时间:2024/04/27 22:28
http://www.codeproject.com/dotnet/HeaderOnEachPage.asp
Introduction
In many situations we might use a DataGrid for reporting purposes. If the report contains many pages we will face the problem of the header only appearing on the first page, and not printing on all pages. With a little JavaScript and CSS we can easily solve this issue.
Using the code
A DataGrid will be rendered as a table element.
If you apply the following CSS rule to THEAD
elements:
tHead{ display : table-header-group;}
then everything in a THEAD
tag will be printed on every page. However, the DataGrid will not render a THEAD
. So the above style will not work. We can add a THEAD
to the table(rendered by the DataGrid) with the following JavaScript code.
function AddTHEAD(tableName){ var table = document.getElementById(tableName); if(table != null) { var head = document.createElement("THEAD"); head.style.display = "table-header-group"; head.appendChild(table.rows[0]); table.insertBefore(head, table.childNodes[0]); }}
The parameter ‘tableName’ is the ID of the datagrid. Calling this function from Onload will work.
<body onload="javascript: AddTHEAD('DataGrid')">
The function create a THEAD
tag and add the first row of the table (header) to it. If the header consists of more than one row you need to add the necessary rows to the created THEAD
.
- How to include a header on each page when printing a DataGrid
- How to freeze a dynamic aspx page into a static html page (on the server).
- How to freeze a dynamic aspx page into a static html page (on the server).
- How To Determine When a Page Is Done Loading in WebBrowser Control
- Spring MVC – How To Include JS Or CSS Files In A JSP Page
- Spring MVC – How to include JS or CSS files in a JSP page
- Spring MVC – How to include JS or CSS files in a JSP page
- When and how to use a ThreadLocal
- How to create a minimal master page
- How to Create A Facebook Page
- How to Make a Single Page Website
- Repeat Tablix Row Header on each page
- HOW TO: remove the 300ms delay when clicking on a link in JQuery Mobile
- add a response header on nginx when using proxy_pass
- How to deploy a .Net assmebly for COM use through CAB on Web Page (转)
- How to deploy a .Net assmebly for COM use through CAB on Web Page
- How to Capture the Row Selected on Search Page In a Variable?
- Primefaces: How to set page on datatable after inserting a new row
- 《你该怎样工作>摘要
- 用java通过odbc连mysql
- 这可能吗?有谁可以解出来?!
- server.xml配置简介
- 关于Apache Portable Runtime and Tomcat
- How to include a header on each page when printing a DataGrid
- 离开了工作近3年的公司
- 小猫不见一天
- 关掉一个用任务管理器关不了的进程
- Create MSDN-style class documentation CHM files for your assemblies
- Linux下使用中文、字体
- vs2005常用快捷键
- 关于Ubuntu字体美化
- Linux下使用中文、字体、版