如何使用javascript仅打印gridview中的选定(指定)列 [英] How to print only selected(specified) columns in gridview using javascript

查看:66
本文介绍了如何使用javascript仅打印gridview中的选定(指定)列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在网格视图中有列(例如)



< b> Id 名字 姓氏



123代码项目





现在我想打印如下,没有Id栏。





名字 姓氏



代码项目



要打印gridview使用的javascript是:



函数CallPrint(){
var prtContent = document.getElementById( divPrint);

var WinPrint = window.open(' '' prtContent'' left = 100,top = 100,width = 100,height = 100,toll​​bar = 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 Lastname

123 Code Project


Now I want to print it as below without Id column.


Firstname Lastname

Code Project

To 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 it
How 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 u


When printing the page,
first hide the unwanted columns
then call the print() function
and then show previously hide columns

Hide grid view column using 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[^]


Refer these solutions-

How to print the gridview selected columns?[^]

http://forums.asp.net/t/1240005.aspx[^]


这篇关于如何使用javascript仅打印gridview中的选定(指定)列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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