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

[Solved] how to print the contents of details table ??

5 Answers 199 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 29 Sep 2009, 08:45 PM
Hello,

I had a linkbutton (to print) for each row in the master table and whenever the linkbutton is clicked the details table records needs to be printed.

Currently I am able to export the details table contents to excel (I had a linkbutton similar to print on each row for exporting). apart from the export I also need the functionality to print the contents of the details table.

Any ideas on this??

Help would be greatly appreciated.

Thanks,
Kevin

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 29 Sep 2009, 09:58 PM
Hello Kevin,

I recommend you examine the following code-library:

RadControls for ASP.NET and ASP.NET AJAX Grid - Print RadGrid contents


It could give you an idea how to achieve the desired functionality.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kevin
Top achievements
Rank 1
answered on 30 Sep 2009, 01:12 PM
Thanks for the reply Daniel

I have already went through that post, My requirement here is to print a details table specific to row. As I said when the user clicks on the print button on the row, the details table records specific to that row needs to be printed. whereas the post you have suggested me prints whole grid.

any idea on printing child table record specific to each row ??

thanks,

Kevin

0
Daniel
Telerik team
answered on 06 Oct 2009, 02:25 PM
Hello Kevin,

Please test the attached demo and let me know if you need further assistance.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kevin
Top achievements
Rank 1
answered on 06 Oct 2009, 09:04 PM
Thanks for the code sample Daniel,

I tried the code sample which you have sent but it is not working. I am binding the detail table on DetailTableDataBind event.

 function PrintRadGrid()  
                {  
                    var previewWnd = window.open('about:blank', '', '', false);  
                    var sh = '<%= ClientScript.GetWebResourceUrl(radGridWellTest.GetType(),String.Format("Telerik.Web.UI.Skins.{0}.Grid.{0}.css",radGridWellTest.Skin)) %>';  
                    alert(sh);  
                    var styleStr = "<html><head><link href = '" + sh + "' rel='stylesheet' type='text/css'></link></head>";  
                    alert(styleStr);  
                    var detailTable = $find('<%= radGridWellTest.ClientID %>').get_detailTables()[0];  
                    alert(detailTable);  
                    var htmlcontent = styleStr + "<body><div class='RadGrid RadGrid_Simple'>" + detailTable.get_element().outerHTML + "</div></body></html>";  
                    alert(htmlcontent);  
                    previewWnd.document.open();  
                    previewWnd.document.write(htmlcontent);  
                    previewWnd.document.close();  
                    previewWnd.print();  
                } 

<telerik:GridTemplateColumn HeaderText="Print" UniqueName="Pprint" HeaderStyle-Font-Bold="true">  
                            <ItemTemplate> 
                                <asp:LinkButton ID="pprint" CommandName="pprint" Text="print" runat="server" OnClientClick="PrintRadGrid(); return false;" Font-Underline="false" ForeColor="Black" ></asp:LinkButton> 
                            </ItemTemplate> 
</telerik:GridTemplateColumn>

as you see in the javascript function, i have inserted some alert boxes and here is what I am getting

for sh:
/wrdt/webresource.axd?d=kypNAC-BENY-ePK8kLJXJuJBxMVdH1mL4pWAKgzHxSfIenb3JiO5fZ0sANDdC2ZhVfeafIcGKsUsT4biZcY1PA2&t=633819906320000000

for style str:
<html><head><link href = '/wrdt/webresource.axd?d=kypNAC-BENY-ePK8kLJXJuJBxMVdH1mL4pWAKgzHxSfIenb3JiO5fZ0sANDdC2ZhVfeafIcGKsUsT4biZcY1PA2&t=633819906320000000' rel='stylesheet' type='text/css'></link></head>

for detailTable:
undefined.

is there anyway to solve this issue??

Thanks,

Kevin

0
Daniel
Telerik team
answered on 12 Oct 2009, 09:20 AM
Hello Kevin,

It seems that the first item is not expanded and therefore your detailTable variable is undefined. Could you please check this out?

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Kevin
Top achievements
Rank 1
Share this question
or