本文介绍了如何在打印时隐藏Gridview第1列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我的javascript代码 - < script 类型 = text / javascript > function printGrid(){ var gridData = document.getElementById(' <% = GridView1.ClientID %> '); var windowUrl ='about:blank'; //为gridview设置打印文档名 var uniqueName = new Date(); var windowName ='Print_'+ uniqueName.getTime(); var prtWindow = window.open(windowUrl,windowName,'left = 100,top = 100,right = 100,bottom = 100,width = 700,height = 500'); prtWindow.document.write('< html > < head > ; < / head > '); prtWindow.document.write('< body style = background:none !important > '); prtWindow.document.write(gridData.outerHTML); prtWindow.document.write('< / body > < / html > '); prtWindow.document.close(); prtWindow.focus(); prtWindow.print(); prtWindow.close(); } < / script > plz帮助如何隐藏gridview中的第1列.......... 解决方案 请看下面的解决方案 < script type = text / javascript> function printGrid(){ var gridData = document .getElementById(' <%= GridView1.ClientID%> ;'); var windowUrl = ' 约:空白'; // 为gridview设置打印文档名称 var uniqueName = new Date (); var windowName = ' Print _' + uniqueName.getTime(); var prtWindow = window .open(windowUrl,windowName, ' left = 100,top = 100,right = 100,bottom = 100,width = 700,height = 500' ) prtWindow。 document .write(' < html>< head>< / head>'); prtWindow。 document .write(' < ; body style =background:none!important>'); prtWindow。 document .write(gridData.outerHTML); prtWindow。 document .write(' < ; /体>< / HTML>'); // 弹出窗口行 var rows = prtWindow。 document .getElementById(' <%= GridView1.ClientID%>')。rows; for ( var i = 0 ; i< rows.length; i ++){ // 删除第一列 rows [i] .deleteCell( 0 ); } prtWindow。 document .close(); prtWindow.focus(); prtWindow.print(); prtWindow.close(); } 您可以参考以下链接隐藏列仅打印Gridview的选定列 [ ^ ] my javascript code -<script type="text/javascript"> function printGrid() { var gridData = document.getElementById('<%=GridView1.ClientID %>'); var windowUrl = 'about:blank'; //set print document name for gridview var uniqueName = new Date(); var windowName = 'Print_' + uniqueName.getTime(); var prtWindow = window.open(windowUrl, windowName, 'left=100,top=100,right=100,bottom=100,width=700,height=500'); prtWindow.document.write('<html><head></head>'); prtWindow.document.write('<body style="background:none !important">'); prtWindow.document.write(gridData.outerHTML); prtWindow.document.write('</body></html>'); prtWindow.document.close(); prtWindow.focus(); prtWindow.print(); prtWindow.close(); } </script>plz help how to hide 1st column in gridview.......... 解决方案 Please have a look into below solution<script type="text/javascript"> function printGrid() { var gridData = document.getElementById('<%=GridView1.ClientID %>'); var windowUrl = 'about:blank'; //set print document name for gridview var uniqueName = new Date(); var windowName = 'Print_' + uniqueName.getTime(); var prtWindow = window.open(windowUrl, windowName, 'left=100,top=100,right=100,bottom=100,width=700,height=500') prtWindow.document.write('<html><head></head>'); prtWindow.document.write('<body style="background:none !important">'); prtWindow.document.write(gridData.outerHTML); prtWindow.document.write('</body></html>'); //get pop up window rows var rows = prtWindow.document.getElementById('<%=GridView1.ClientID %>').rows; for (var i = 0; i < rows.length; i++) { // remove first column rows[i].deleteCell(0); } prtWindow.document.close(); prtWindow.focus(); prtWindow.print(); prtWindow.close(); }You can refer following link to hide the columns Printing only selected colums of Gridview[^] 这篇关于如何在打印时隐藏Gridview第1列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-20 09:56