Printing RadTree content

5 posts, 1 answers
  1. blue123
    blue123 avatar
    14 posts
    Member since:
    Feb 2009

    Posted 11 May 2012 Link to this post

    I have a radtree inside a div and I have two buttons inside that same div:  " Print Report" and Print Detailed Report" . "Print report" will print the div with radtree collapsed and "Print Detailed Report" will print the div with radtree expanded. I am using javascript to do that. Now, everything works fine in IE but in Firefox, I am not able to print the div with radtree expanded. I can see radtree expanding on the webpage but not on the window for printing. It prints that div with radtree collapsed. Here is my javascript:
    for Collapsed radtree:

     

     

    function PrintMe(node) {

     

     

     

    var content = node.innerHTML;

     

     

     

    var pwin = window.open('', 'print_content', 'width=800,height=700,scroll=no');

     

    pwin.document.open();

    pwin.document.write(

     

    '<html><body onload="window.print()">' + content + '</body></html>');

     

    pwin.document.close();

    setTimeout(

     

    function () { pwin.close(); }, 1000);

     

    }
    for Expanded Radtree:

     

     

    function printSelection(node) {

     

     

     

    var treeView = $find("<%= rdTreeDetails.ClientID %>");

     

     

     

    var nodes = treeView.get_allNodes();

     

     

     

    for (var i = 0; i < nodes.length; i++) {

     

     

     

    if (nodes[i].get_nodes() != null) {

     

     

     

    if (nodes[i].get_nodes().get_count() != 0) {

     

    nodes[i].expand();

    }

    }

    }

     

     

    var content = node.innerHTML;

     

     

     

    var pwin = window.open('', 'print_content', 'width=800,height=700,scroll=no');

     

    pwin.document.open();

    pwin.document.write(

     

    '<html><body onload="window.print()">' + content + '</body></html>');

     

    pwin.document.close();

     

    setTimeout(

     

    function () { pwin.close(); }, 1000);

     

     

     

    for (var j = 0; j < nodes.length; j++) {

     

     

     

    if (nodes[j].get_nodes() != null) {

     

     

     

    if (nodes[j].get_nodes().get_count() != 0) {

     

    nodes[j].collapse();

    }

    }

    }

    }

    What can be done to print it expanded in firefox?

  2. blue123
    blue123 avatar
    14 posts
    Member since:
    Feb 2009

    Posted 14 May 2012 Link to this post

    bump!!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 16 May 2012 Link to this post

    Hello Kavita,

     
    I have inspected your code but unfortunately could not make it work in neither IE nor FireFox. I am attaching my test web page. Would you please elaborate a little bit what is the expected behavior, let me know what else should be added to the project and may be make a video how it works properly at your side so we can think of a possible solution?

    All the best,
    Plamen Zdravkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. blue123
    blue123 avatar
    14 posts
    Member since:
    Feb 2009

    Posted 16 May 2012 Link to this post

    Try this fo button click and see if you can make it work:

     

     

    <div align="center"><button onclick="PrintMe(document.getElementById('MainContent_mainDiv'));return false">Print Report</button> &nbsp;&nbsp;<button onclick="printSelection(document.getElementById('MainContent_mainDiv'));return false">Print Detailed Report</button></div>

     


    and this is the div (which contains radtree), I am trying to print the content for:

     

     

    <div id="mainDiv" runat="server"></div>

     

  6. Answer
    Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 21 May 2012 Link to this post

    Hello,

     
    I inspected the issue once again and updated the sample test page from the previous post in order to implement a working simple printing functionality.

    Hope this code will be helpful.

    Kind regards,
    Plamen Zdravkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017