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

Unable to print radgrid in Mozilla for some pages

2 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Winni
Top achievements
Rank 1
Winni asked on 29 Jul 2011, 12:23 PM

Hi,
With the help of the posts in  http://www.telerik.com/community/forums/aspnet/grid/72051-radgrid-print.aspx#1532370 I could print the entire contents of radgrid in Internet Explorer and mozilla .But  I am not able to print the radgrid of certain web pages of the application  in same version of   mozilla while able to do that in internet explorer.For those pages, the below function PrintRadGrid returns null for $find(radGridId).

For the non-working pages , if i put a alert  as the first line of the function PrintRadGrid , then it is working

Could any body please explain why this happens and  how to make it working ...

function getOuterHTML(obj) {
            if (typeof (obj.outerHTML) == "undefined") {
                var divWrapper = document.createElement("div");
                var copyOb = obj.cloneNode(true);
                divWrapper.appendChild(copyOb);
                return divWrapper.innerHTML
            }
            else
                return obj.outerHTML;
        }

        function PrintRadGrid(radGridId) {

            var radGrid = $find(radGridId);
            var previewWnd = window.open('about:blank', '', '', false);
            var sh = '<%# ClientScript.GetWebResourceUrl(grdName.GetType(),String.Format("Telerik.Web.UI.Skins.{0}.Grid.{0}.css",grdName.Skin)) %>';
            var styleStr = "<html><head><link href = '" + sh + "' rel='stylesheet' type='text/css'></link></head>";
            var htmlcontent = styleStr + "<body>" + getOuterHTML(radGrid.get_element().parentNode) + "</body></html>";
            previewWnd.document.open();
            previewWnd.document.write(htmlcontent);
            previewWnd.document.close();
            previewWnd.print();
            previewWnd.close();

            radGrid.get_masterTableView().fireCommand("EnablePaging", "");
        } 

And in code behind

 RadPnl.ResponseScripts.Add("PrintRadGrid('" + grdNmae.ClientID + "')");

Thanks

 

 

2 Answers, 1 is accepted

Sort by
0
Winni
Top achievements
Rank 1
answered on 01 Aug 2011, 06:38 AM
It is found that the pages which place the "print" button inside CommandItemTemplate work fine with the above print code.
Buttons placed outside failed to give expected result as the find(radGrid) returns null.
From code behind correct value(radGrid clientId) is passed to java script function.
Is there any way to get it done?
0
Daniel
Telerik team
answered on 04 Aug 2011, 03:28 PM
Hello Soumya,

Try the following modification and let me know what happens:
Javascript:
var radGrid = $telerik.findControl(document, radGridId);
 
C#:
RadPnl.ResponseScripts.Add("PrintRadGrid('" + grdNmae.ID+ "')");


Kind regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Winni
Top achievements
Rank 1
Answers by
Winni
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or