如何在打印时隐藏Gridview第1列 [英] How to hide Gridview 1st column in print time

查看:50
本文介绍了如何在打印时隐藏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列..........

解决方案

< blockquote>请看下面的解决方案



< 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(' < span class =code-string><%= 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列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆