printing grid

3 posts, 0 answers
  1. danielnp20
    danielnp20 avatar
    22 posts
    Member since:
    Jun 2008

    Posted 05 Aug 2008 Link to this post

    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. Anil
    Anil avatar
    58 posts
    Member since:
    Nov 2007

    Posted 06 Aug 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2008 Link to this post

    Hi Daniel,

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

    Thanks
    Shinu

Back to Top