【问题标题】:Print content of a JavaScript tabcontrol: Gridviews打印 JavaScript 选项卡控件的内容:Gridviews
【发布时间】:2010-04-28 19:45:17
【问题描述】:

我有一个 jQuery 选项卡控件(4 个选项卡),每个选项卡控制 1 个网格视图。 现在我有一个按钮“打印”。它激活了一个 JavaScript 函数,该函数应该构建一个包含所有网格视图的页面。我得到了一些东西,但它不起作用:

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);
        myWindow.document.close();
        myWindow.focus();
        myWindow.print();
        return true;
    }

我认为可能是getElementByID(),然后是tabcontainer(包含选项卡)或tabcontent(每个选项卡的内容)或GridView1之类的东西,但我可能完全错了。因为我不知道...

【问题讨论】:

    标签: c# asp.net javascript jquery printing


    【解决方案1】:

    解决方案:

    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;
    
    }
    

    嵌入在 div ("tab#") 中的单独网格视图,其中嵌入在 tabcontainer 中。简单的解决方案...选择正确的 div ID... 显然我忽略了这个

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多