This is a migrated thread and some comments may be shown as answers.

Printing RadTree content

4 Answers 92 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
blue123
Top achievements
Rank 1
blue123 asked on 11 May 2012, 10:26 PM
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?

4 Answers, 1 is accepted

Sort by
0
blue123
Top achievements
Rank 1
answered on 14 May 2012, 02:46 PM
bump!!
0
Plamen
Telerik team
answered on 16 May 2012, 04:48 PM
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.
0
blue123
Top achievements
Rank 1
answered on 16 May 2012, 06:18 PM
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>

 

0
Accepted
Plamen
Telerik team
answered on 21 May 2012, 03:24 PM
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.
Tags
TreeView
Asked by
blue123
Top achievements
Rank 1
Answers by
blue123
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or