MyITBlog.com - IT Professionals Online Journal
 
  Home  |   Site News  |   About Us  |   Privacy  |   FAQ  |   Contact   Add Blog Entry  |  Login  |  Register   
 My Account
Username
Password
Remember me
Lost Password?


 Categories


  HOME  >  Programming  >  MicrosoftPrint


1
Vote
Displaying Grid Header in every page when Printing in Microsoft   
by Thivya on 03 Mar 2006, 00:55     Read Thivya's Blog
Total Hits: 647    Comments: 0   

Often we will have a requirement like printing the Grid header in every page when it's printed out. You can do this using Javascript, by just changing the Grid Header row style to "display:table-header-group"

just give the below code in your page script section

function print_header() {

var table = document.getElementById("dataGrid1"); // the id of your DataGrid

var str = table.outerHTML;

//replace the starting TBODY tag to empty string
str = str.replace("<TBODY>", "");

//replace the grid first row (header) tag with the Table Header details

str = str.replace("<TR", "<THEAD style='display:table-header-group'><TR");

//replace the closing tag of the First Row (header) with the closing tag of the THEAD tag

str = str.replace("</TR>", "</TR></THEAD><TBODY>");

table.outerHTML = str;
}

Call this function once you have generated the grid.

 


 

Post Comment

Copyright © 2008 MyITBlog.com