How to give print option to datagrid?
-
Hi, I have a datagrid in my application. I would like provide an option, whenever that event is fired, the data in datagrid should be printed. How can I do this? could you please give some idea. Thanks and Regards Gowtham Sen
-
Hi, I have a datagrid in my application. I would like provide an option, whenever that event is fired, the data in datagrid should be printed. How can I do this? could you please give some idea. Thanks and Regards Gowtham Sen
put the datagrid in a div and when click on the button call a javascript function which will print the grid. function will be as following : function CallPrint() { var prtContent = document.getElementById('Test1'); var WinPrint = window.open("Print.aspx",'Print','scrollbars=yes,resizable=yes,width=900,height=600,top=200,left=200'); WinPrint.document.write(prtContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); prtContent.innerHTML=strOldOne; return false; } here 'Test1' is teh id of div in which grid wil be there. and print.aspx will be new window which wil be open as a print preview.
-
put the datagrid in a div and when click on the button call a javascript function which will print the grid. function will be as following : function CallPrint() { var prtContent = document.getElementById('Test1'); var WinPrint = window.open("Print.aspx",'Print','scrollbars=yes,resizable=yes,width=900,height=600,top=200,left=200'); WinPrint.document.write(prtContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); prtContent.innerHTML=strOldOne; return false; } here 'Test1' is teh id of div in which grid wil be there. and print.aspx will be new window which wil be open as a print preview.
Hai Goyal Manish, Thanks a lot. Its working very good. I was surprised very much. If you don't mind can you explain the code line by line briefly. Thanks and Regards Gowtham Sen.
-
Hai Goyal Manish, Thanks a lot. Its working very good. I was surprised very much. If you don't mind can you explain the code line by line briefly. Thanks and Regards Gowtham Sen.
Dear Manish, I have one problem that, the datagrid is in the middle of the page. So while I am viewing in the print view, more space is wasted at the header. can we edit the print view page and then print as we want. Is it possible? Another thing is, how to zoom the page. How can we set this option fot it? Could you please give me some idea. Thanks and Regards Gowtham Sen