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

printing grid

2 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 05 Aug 2008, 03:51 PM
I thought this would be easy, but i cant find where i can read about it. The idea is very simple how to print all the registers from the grid? or algo the page in context?..

I supossed this functionality is already written, but i dont know where.

please where i can read about it

2 Answers, 1 is accepted

Sort by
0
Anil
Top achievements
Rank 2
answered on 06 Aug 2008, 05:48 AM
Hi Daniel,

you can write a javascript  function for that. i have tried the below one hope it helps you.

function print(GridID)
{
    newwindow=window.open("");
    newwindow.document.open();
     
    var headerText = "";
    headerText = "<TABLE class='MasterTable_Office2007'>";
    headerText += document.getElementById(GridID + '_GridHeader').children[0].children[0].outerHTML;
    headerText += "<THEAD><TR>";
    try
    {
    for(var i=0;i<document.getElementById(GridID + '_GridHeader').children[0].children[1].children[0].children.length;i++)
    {
        if(document.getElementById(GridID + '_GridHeader').children[0].children[1].children[0].children[i].children.length > 0)
        {
            if(document.getElementById(GridID + '_GridHeader').children[0].children[1].children[0].children[i].children[0].children.length > 0)
            {
                headerText += "<TH class= 'GridHeader_Office2007' style='font-weight: bolder;font-size: 11px;text-align: left;'>"+document.getElementById(GridID + '_GridHeader').children[0].children[1].children[0].children[i].children[0].children[0].innerText+"</TH>";
            }
        }
    }
    }
    catch(e){}
    headerText += "</TR></THEAD></TABLE>";
   
    newwindow.document.write
    (   "<html>" +
        "<link href=" + "'RadControls/Grid/Skins/Office2007/Styles.css\' rel='stylesheet' type='text/css' />" +
        "<table border=1 borderColor=#94A5BC cellspacing=0 cellpadding=0><tr><td style='border:0'>" +
        headerText +
        document.getElementById(GridID + '_GridData').innerHTML +
        "</td></tr></table></html>"); 
   
    newwindow.document.close();
    newwindow.focus();
    newwindow.print();    
}

this function works fine for my application. Change the things according to your application and try.

Thanks
Anil
0
Shinu
Top achievements
Rank 2
answered on 06 Aug 2008, 06:23 AM
Hi Daniel,

Another method is to Export  the Grid and print the Grid from Word or Excel.

Thanks
Shinu

Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Anil
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Share this question
or