How to include a header on each page when printing a DataGrid
2006-08-13 11:53
465 查看
http://www.codeproject.com/dotnet/HeaderOnEachPage.asp
If you apply the following CSS rule to
then everything in a
The parameter ‘tableName’ is the ID of the datagrid. Calling this function from Onload will work.
The function create a
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
THEADelements:
tHead { display : table-header-group; }
then everything in a
THEADtag 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
THEADto 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
THEADtag 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 tag a photo to be used as a thumbnail when page is linked to on facebook
- How to freeze a dynamic aspx page into a static html page (on the server).
- How to get unique visitors per page on Google Analytics?
- How to fix 远程计算机需要网络级别身份验证 when using mstsc on XP
- Primefaces: How to set page on datatable after inserting a new row
- How to pass the value to the function when clicking on the UIButton
- How to freeze a dynamic aspx page into a static html page (on the server).
- How-to launch browser print dialog when showing printable page
- How to Embed a Web Page on Another Site?
- Spring MVC – How To Include JS Or CSS Files In A JSP Page
- 网页打印时去除页眉页脚(Removing Header&Footer when printing page)
- Repeat Tablix Row Header on each page
- How to specify image folder path for each user when use TinyMce ImageManager with Symfony
- How to grant access to SQL logins on a standby database when the guest user is disabled in SQL Serve
- How to use Ajax on Visualforce page on Salesforce platform
- How to change upsell product display number on product view page?
- How to reclaim space in InnoDB when innodb_file_per_table is ON
- How to Capture the Row Selected on Search Page In a Variable?
- How to display custom select option on product list page?
- how to loop through the Params property for a page and how to display each key/value pair