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

Print RadPane

12 Answers 116 Views
Splitter
This is a migrated thread and some comments may be shown as answers.
Vijaianand
Top achievements
Rank 1
Vijaianand asked on 11 Jan 2012, 06:09 PM
I just want to print the content in the radpane. I tried options provided in other thread but getting error. There are links in those threads which are erroring out. I like know the right way/ right javascript code to do print with any scripts which needed to be included to get it working.

Below is my code
<script type="text/javascript">
    function PrintPane(paneID)
    {
      var splitter = <%= RadSplitter1.ClientID %>;
      alert(paneID);
      var pane = splitter.GetPaneById(paneID);
      if (!pane) return;
      pane.Print();
    }
</script>

12 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 11 Jan 2012, 09:07 PM
Hello Vijaianand,

I don't know if this is causing your issue, but with javascript being case-sensitive. The method call, GetPaneById, should be getPaneById.
0
Princy
Top achievements
Rank 2
answered on 12 Jan 2012, 06:01 AM
Hello,

Take a look into the following documentation.
Printing Pane Content

Thanks,
Princy.
0
Vijaianand
Top achievements
Rank 1
answered on 12 Jan 2012, 02:30 PM
Hello

@Kevin, all the examples in the forum gives GetPaneById only. So thats why I am using it.
@Princy, Please read my question with the code. I already have the code but trying to say its not working.  It is giving object not find on GetPaneById
0
Vijaianand
Top achievements
Rank 1
answered on 12 Jan 2012, 02:59 PM
Actually, i made a mistake in find the splitter client id, I fixed that line
var splitter = $find('<%=RadSplitter1.ClientID %>');

No error now. but still printing is not working. It just not doing anything at the end. 
0
Dobromir
Telerik team
answered on 12 Jan 2012, 07:36 PM
Hi Vijaianand,

According to the error, that you have already noticed yourself, I believe the examples that you have found are for RadSplitter Classic, that is why the GetPaneById() and Print() methods are capitalized, but this should not be the problem because RadSplitter for ASP.NET AJAX have those methods too.

I tried the sample from the help article that Princy linked and I was able to to print the panes content without any errors. For your convenience I have attached my sample page, could you please modify it to a point where the problem occurs and send it back?

In addition, in your initial post you are mentioning dead links - "There are links in those threads which are erroring out". Could you please point those thread so we can try to provide the correct links (if possible).

Greetings,
Dobromir
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
Vijaianand
Top achievements
Rank 1
answered on 12 Jan 2012, 07:48 PM
Hi

Actually its not RadPane, its RadSlidingPane. So I am not sure that may be the issue. Is it possible print slidingpane? I thought it should be same as RadPane.
There are lots of dead links you can find when you and search for "RadPane Printing" in the form.

Vijai
0
Dobromir
Telerik team
answered on 12 Jan 2012, 08:38 PM
Hi Vijai,

RadSlidingPane does not offer the possibility to print its content out-of-the-box, nevertheless, you can use the following function to achieve the required result:
function printSlidingPaneContent(slidingPaneId, arrCssFiles)
{
    var sPane = $find(slidingPaneId);
    var sFeatures = 'width=' + sPane.get_width() + 'px, height=' + sPane.get_height() + 'px, scrollbars=1';
    var previewWndUrl = 'about:blank';
    var previewWnd = window.open(previewWndUrl, '', sFeatures, false);
 
    //CSS files to be included in the popup window
    var styleStr = "";
    if (arrCssFiles) {
        styleStr = "<head>";
 
        for (var i = 0, length = arrCssFiles.length; i < length; i++) {
            styleStr += "<link href = '" + arrCssFiles[i] + "' rel='stylesheet' type='text/css'></link>";
        }
        styleStr += "</head>";
    }
 
    var popupContent = styleStr + "<body>" + sPane.getContent() + "</body>"
 
    previewWnd.document.open();
    previewWnd.document.write(popupContent);
    previewWnd.document.close();
 
    previewWnd.print();
}

For your convenience I have attached a sample page demonstrating this approach.

Greetings,
Dobromir
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
Vijaianand
Top achievements
Rank 1
answered on 12 Jan 2012, 08:57 PM
That works except the height and width from Slidingpane is properly getting it. It set to Min width and height..

Thanks. May be should have searched for SlidingPane print instead of RadPane. 
0
Vijaianand
Top achievements
Rank 1
answered on 15 Feb 2012, 05:08 PM
Hi

I am having issue with this solution when the RadSlidePane has iframe. It is not taking iframe content to print. How can we fix that issue? I was thinking may be take the content of the page which is iframed and add in the popcontent but I was wondering any other solution possible.

Vijai
0
Dobromir
Telerik team
answered on 20 Feb 2012, 10:51 AM
Hi Vijai,

In general, the printing functionality is controlled by the browser and the OS and cannot be modified programmatically.

RadSplitter does not offer the functionality to display external content inside its sliding panes, and does not offer functionality to access the content of <iframe> elements out-of-the-box.

If you are using an <iframe> to display external content inside RadSlidingPane you need to manually extract the content of this <iframe> and add it to the preview's popup window. However, accessing the content of an <iframe> element is not always possible because of a security restriction in JavaScript - you cannot access content of an <iframe> if the page displayed inside it is from different domain.

Regards,
Dobromir
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Vijaianand
Top achievements
Rank 1
answered on 21 Feb 2012, 02:57 PM
ok! I know RadSplitter don't support print and thats why I am trying different ways.

So if I understand correctly, I won't be to able to extract content from iframe if the url is from different domain but if its same domain it is possible? I tried many ways using javascript, jquery to extract it out but still no luck. Do you have any code sample?
0
Accepted
Dobromir
Telerik team
answered on 24 Feb 2012, 10:21 AM
Hi Vijai,

Please review the following RadEditor's Demo.
http://demos.telerik.com/aspnet-ajax/editor/examples/customdialogs/defaultcs.aspx

The custom PrintPreview dialog is using an IFrame and prints its content.

Regards,
Dobromir
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
Splitter
Asked by
Vijaianand
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Vijaianand
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or