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

Export to excel, Pdf

4 Answers 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jayanthi
Top achievements
Rank 1
jayanthi asked on 14 May 2012, 06:12 AM
Hello,

Am using vb.net
I have master table and detail table in Radgrid.
Now how to export only detail table records to excel & pdf?

Thank you
Jayanthi

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 May 2012, 07:44 AM
Hello Jayanthi,

Try the following code to achieve your scenario.
VB:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs)
    If e.CommandName = RadGrid.ExportToPdfCommandName Then
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = True
              RadGrid1.MasterTableView.DetailTables(0).HierarchyDefaultExpanded = True
    End If
    If e.CommandName = RadGrid.ExportToExcelCommandName Then
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = True
        RadGrid1.MasterTableView.DetailTables(0).HierarchyDefaultExpanded = True
    End If
End Sub

Thanks,
Princy.
0
jayanthi
Top achievements
Rank 1
answered on 14 May 2012, 08:00 AM
Hi,

I have defined export settings as below

 

 

<ExportSettings FileName="Question-Paper-IL" HideStructureColumns="true" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">

 

 

 

<Excel Format="ExcelML" />

 

 

 

<Pdf DefaultFontFamily="Tahoma" Producer="Question-Paper-IL" PageTitle="Question Paper IL Report" FontType="Subset" />

 

</

 

 

ExportSettings>
It throws the following error

 

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

If i remove the above code then excel export works but it also exports the controls.

Help me

0
jayanthi
Top achievements
Rank 1
answered on 15 May 2012, 05:23 AM
Hi Princy,
RadGrid1.MasterTableView.DetailTables(0).HierarchyDefaultExpanded = True

The above line throws the below error.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

 

If i remove that code, master table and detail table data are exporting in PDF with detail table Command Item link buttons. How to control exporting the controls?

I am calling .ascx in detail table while clicking 'Add New' command item link button. While cancel it collapse the detail and master table which i dont want. So i used the below code:
rgView1.MasterTableView.DetailTables(0).HierarchyDefaultExpanded = True
It doesnt collapse the detail table, but .ascx page still exists, i need only the detail table rows. How to achieve it?

I have attached the image file with this.

Its urgent.
Guide me

0
Daniel
Telerik team
answered on 17 May 2012, 09:00 AM
Hi Jayanthi,

You can borrow some ideas from the attached sample.
Let us know if you need more information.

Regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
jayanthi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
jayanthi
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or