本文介绍了如何使用javascript仅打印gridview中的选定(指定)列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 我在网格视图中有列(例如) Id 名字 姓氏 123代码项目 现在我想打印如下,没有Id栏。 名字 姓氏 代码项目 要打印gridview使用的javascript是: 函数CallPrint(){ var prtContent = document.getElementById( divPrint); var WinPrint = window.open(' ',' prtContent',' left = 100,top = 100,width = 100,height = 100,tollbar = 0,scrollbars = 1,status = 0,resizable = 1'); datagridview.Columns [ 0 ]。可见= false ; WinPrint.document.write(prtContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); } 如何使用javasript实现这一目标。 谢谢,解决方案 与下面的链接'解决方案1相同......但你必须做一些小事其变化 如何打印gridview选定的列? [ ^ ] 函数CallPrint(){ var prtContent = document.getElementById(' <%= GridView1.ClientID%>'); prtContent.border = 1 ; // 此处不设置边框 var WinPrint = window.open(' ',' ',' 左= 0,顶部= 100,宽度= 80,高度= 100,工具栏= 0,滚动条= 1,状态= 0,可调整大小= 1' ); WinPrint.document.write(prtContent.outerHTML); var rows = WinPrint.document.getElementById( GridView1)。rows; for ( var i = 0 ; i< rows.length; i ++) { rows [i] .deleteCell( 0 ); } WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); } 浏览你的页面浏览页面后你会理解诀窍...... 希望它能帮助你 打印页面时, 首先隐藏不需要的列 然后调用print()函数 然后显示以前隐藏的列 使用javascript隐藏网格视图列 http://forums.asp.net/t/1542978.aspx/1 [ ^ ] http://stackoverflow.com/questions/6068348/javascript-hide-multiple-gridview-rows [ ^ ] http://aspdotnetcodebook.blogspot.com/2008/03/how-to-hide-gridview-column-using.html [ ^ ] 参考这些解决方案 - 如何打印gridview选定的列? [ ^ ] http://forums.asp.net/t/1240005.aspx [ ^ ] Hi all,I have columns in a gridview like(For eg)Id Firstname Lastname123 Code ProjectNow I want to print it as below without Id column. Firstname Lastname Code ProjectTo print gridview used javascript is :function CallPrint() { var prtContent = document.getElementById("divPrint"); var WinPrint = window.open('', 'prtContent ', 'left=100,top=100,width=100,height=100,tollbar=0,scrollbars=1,status=0,resizable=1'); datagridview.Columns[0].Visible = false; WinPrint.document.write(prtContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close();}How to achieve this by using javasript.Thank you, 解决方案 same as in below link''s Solution 1 ...but u have to do some little changes in itHow to print the gridview selected columns?[^]function CallPrint() { var prtContent = document.getElementById('<%= GridView1.ClientID %>'); prtContent.border = 1; //set no border here var WinPrint = window.open('','','left=0,top=100,width=80,height=100,toolbar=0,scrollbars=1,status=0,resizable=1'); WinPrint.document.write(prtContent.outerHTML); var rows = WinPrint.document.getElementById("GridView1").rows; for(var i=0;i<rows.length;i++) { rows[i].deleteCell(0); } WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close();}after browsing ur page view source of page u will understand trick...hope it will help uWhen printing the page,first hide the unwanted columnsthen call the print() functionand then show previously hide columnsHide grid view column using javascripthttp://forums.asp.net/t/1542978.aspx/1[^]http://stackoverflow.com/questions/6068348/javascript-hide-multiple-gridview-rows[^]http://aspdotnetcodebook.blogspot.com/2008/03/how-to-hide-gridview-column-using.html[^]Refer these solutions-How to print the gridview selected columns?[^]http://forums.asp.net/t/1240005.aspx[^] 这篇关于如何使用javascript仅打印gridview中的选定(指定)列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 21:00