开发者

Print content of a JavaScript tabcontrol: Gridviews

I've got a jQuery tabcontrol (4 tabs), which each of them control 1 gridview. Now I got a button "print". It activates a JavaScript function, which should build a page, containing all gridviews. I got something, but it does not work:

function doPrintPage() {
        myWindow = window.open('', '', 'titlebar=yes,menubar=yes,status=yes,scrollbars=yes,width=500,height=600');
        myWindow.document.open();
        myWindow.document.writeln("<link href='/styles/Layout.css' type='text/css' rel='stylesheet' ></link>");
        myWindow.document.write(document.getElementById('tabcontainer').innerHTML开发者_C百科);
        myWindow.document.close();
        myWindow.focus();
        myWindow.print();
        return true;
    }

I thought it may be the getElementByID() and then something like tabcontainer (which contains the tabs) or tabcontent (the content of each tab) or GridView1 or something, but I could be completely wrong. As I ain't got a clue...


Solution:

function doPrintPage()
{

myWindow = window.open('', '', 'titlebar=yes,menubar=yes,status=yes,scrollbars=yes,width=800,height=600');

myWindow.document.open();
myWindow.document.write("</br>");
myWindow.document.write("<h2>Results</h2>");
myWindow.document.write(document.getElementById('tab1').innerHTML);
myWindow.document.write("</br>");
myWindow.document.write("<h2>Tree</h2>");
myWindow.document.write(document.getElementById('tab2').innerHTML);
myWindow.document.write("</br>");
myWindow.document.write("<h2>Open</h2>");
myWindow.document.write(document.getElementById('tab3').innerHTML);
myWindow.document.write("</br>");
myWindow.document.write("<h2>Free</h2>");
myWindow.document.write(document.getElementById('tab4').innerHTML);

myWindow.document.close();

myWindow.focus();

//myWindow.print();

//myWindow.close();

return true;

}

The seperate gridviews where embedded in div's ("tab#"), which where embedded in the tabcontainer. Simple solution... select the correct div ID... Apparantly I overlooked this one

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜