Rad grid print

4 posts, 0 answers
  1. Rajeswari
    Rajeswari avatar
    27 posts
    Member since:
    May 2013

    Posted 22 Apr 2015 Link to this post

    Hi

    I am using asp.net vb 2010 . I have a rad grid with pagination . Is there any code sample to print only rad grid data  displayed in all rad grid pages from the server side code .

     

    Thanks for your help

     Rajeswari Raman

     

  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 23 Apr 2015 Link to this post

    Hi,

    To print the grid you should use the approach demonstrated in the following code library. Note that to include all grid pages you also need to set AllowPaging="false":
    http://www.telerik.com/support/code-library/print-radgrid-contents

    Regards,
    Pavlina
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. Rahul
    Rahul avatar
    2 posts
    Member since:
    Sep 2017

    Posted 16 Feb 2018 Link to this post

    Hello All,

    I used the same concept to print all data instead of only first page but in that case paging also get removed on ui which i dont want. Please help me out in that. I am stuck in this from so long.

    Actual requirement:

    On page load we have to bidn the grid with data with allow paging=true and when i click on print i need all data which we have in grid  without paging but in ui it has to show paging.

    Please find attached screenshot and below code which i am using

    Javascript code:
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
                function PrintRadGrid(radGrid)
                {
                    setTimeout(function()
                    {
                        var previewWnd = window.open('about:blank', '', '', false);
                        var styleStr = "<html><head><link href='Styles.css' rel='stylesheet' type='text/css'></link></head>";
                        var htmlcontent = styleStr + "<body>" + $find(radGrid).get_element().outerHTML + "</body></html>";
                        previewWnd.document.open();
                        previewWnd.document.write(htmlcontent);
                        previewWnd.document.close();
                        previewWnd.print();
                        previewWnd.close();
                    }, 100);
                }
            </script>

        </telerik:RadCodeBlock>

     

    Server side code:

     protected void LinkButton1_Click(object sender, EventArgs e)
        {
            radGrid1.AllowPaging = false;
            radGrid1.MasterTableView.AllowFilteringByColumn = false;

            radGrid1.Rebind();
            RadAjaxPanel1.ResponseScripts.Add("PrintRadGrid('" + radGrid1.ClientID + "')");
        }

     

    HTML :

     

     <telerik:RadGrid ID="radGrid1" runat="server" Skin="Simple" DataSourceID="SqlDataSource1"
                    Style="margin: 20px;" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" PageSize="9"
                    GridLines="None">
                </telerik:RadGrid>

  4. Rahul
    Rahul avatar
    2 posts
    Member since:
    Sep 2017

    Posted 16 Feb 2018 Link to this post

    Hello All,

    I used the same concept to print all data instead of only first page but in that case paging also get removed on ui which i dont want. Please help me out in that. I am stuck in this from so long.

    Actual requirement:

    On page load we have to bidn the grid with data with allow paging=true and when i click on print i need all data which we have in grid  without paging but in ui it has to show paging.

    Please find attachedscreenshot and below sample code:

     

    Javascript code:

     <script type="text/javascript">
                function PrintRadGrid(radGrid)
                {
                    setTimeout(function()
                    {
                        var previewWnd = window.open('about:blank', '', '', false);
                        var styleStr = "<html><head><link href='Styles.css' rel='stylesheet' type='text/css'></link></head>";
                        var htmlcontent = styleStr + "<body>" + $find(radGrid).get_element().outerHTML + "</body></html>";
                        previewWnd.document.open();
                        previewWnd.document.write(htmlcontent);
                        previewWnd.document.close();
                        previewWnd.print();
                        previewWnd.close();
                    }, 100);
                }
            </script>

    Server code:

     protected void LinkButton1_Click(object sender, EventArgs e)
        {
            radGrid1.AllowPaging = false;
            radGrid1.MasterTableView.AllowFilteringByColumn = false;

            radGrid1.Rebind();
            RadAjaxPanel1.ResponseScripts.Add("PrintRadGrid('" + radGrid1.ClientID + "')");
        }

    HTML:

     <telerik:RadGrid ID="radGrid1" runat="server" Skin="Simple" DataSourceID="SqlDataSource1"
                    Style="margin: 20px;" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" PageSize="9"
                    GridLines="None">
                </telerik:RadGrid>

Back to Top