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

Rad grid print

3 Answers 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rajeswari
Top achievements
Rank 1
Rajeswari asked on 22 Apr 2015, 06:48 PM

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

 

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 23 Apr 2015, 01:44 PM
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.

 
0
Rahul
Top achievements
Rank 1
answered on 16 Feb 2018, 11:53 AM

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>

0
Rahul
Top achievements
Rank 1
answered on 16 Feb 2018, 11:54 AM

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>

Tags
Grid
Asked by
Rajeswari
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Rahul
Top achievements
Rank 1
Share this question
or