Hi,
We are trying to export the self hierarchical RAD grid in to an excel.The problem is, we are not able to export the detail table contents when the grid is collapsed.our requirement is , if we click the export all button all the grid details should be exported irrespective of master and detail table contents also whether it is expanded or collapsed.Also while exporting, the column header for detail tables should not be exported.
the code we have used in button click event is
RadGrid1.MasterTableView.Columns.FindByUniqueName("ClaimID").Visible = false;
RadGrid1.MasterTableView.Columns.FindByUniqueName("ExportClaimID").Visible = true;
RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
RadGrid1.ExportSettings.OpenInNewWindow = true;
RadGrid1.ExportSettings.IgnorePaging = true;
RadGrid1.Rebind();
RadGrid1.ExportSettings.ExportOnlyData = true;
RadGrid1.MasterTableView.ExportToExcel();
please can any one tell me the solution for this issue.
Quick solution/response will be appreciated.
Regards,
Bharath
7 Answers, 1 is accepted
I am sending you a simple runnable application which handles the desired functionality. Please give it a try and see if it works for you.
I hope this helps.
Regards,
Pavlina
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.
Thanks for the quick solution and we can able to achieve it using your example.
But we need to have one column header.
Here for each detail table there is a column header in excel.
we need to remove that column headers from Excel.
is there any inbuilt functionality in the grid to remove these column headers from the excel?
Thanks in advance.
Regards,
Bharathwajan
Try the following code snippet in the Click event of the Export button to hide the headers for the detail tables:
C#:
| protected void Button1_Click(object sender, EventArgs e) |
| { |
| RadGrid1.MasterTableView.HierarchyDefaultExpanded = true; |
| RadGrid1.MasterTableView.Rebind(); |
| foreach (GridDataItem item in RadGrid1.MasterTableView.Items) |
| { |
| if (item.Expanded) |
| { |
| foreach (GridTableView childTable in item.ChildItem.NestedTableViews) |
| { |
| foreach (GridHeaderItem header in childTable.GetItems(GridItemType.Header)) |
| { |
| header.Visible = false; |
| } |
| } |
| } |
| } |
| RadGrid1.ExportSettings.ExportOnlyData = true; |
| RadGrid1.ExportSettings.OpenInNewWindow = true; |
| RadGrid1.MasterTableView.ExportToExcel(); |
| } |
I hope this helps.
Regards,
Pavlina
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.
Please take look at attached project. I made simple modifications in your example from selfreference-hierarchy-export.zip:
I have added CommandItemDisplay="Top" and EnableNoRecordsTemplate="true" to MasterTableView and added 2 columns
(GridButtonColumn and GridEditCommandColumn).
<MasterTableView HierarchyDefaultExpanded="false" HierarchyLoadMode="Client" EnableNoRecordsTemplate="true" AutoGenerateColumns="False" DataKeyNames="EmployeeID,ReportsTo" Width="100%" CommandItemDisplay="top">
<SelfHierarchySettings KeyName="EmployeeID" ParentKeyName="ReportsTo" />
<Columns>
<telerik:GridButtonColumn UniqueName="DeleteColumn" ButtonType="ImageButton" CommandName="Delete" ItemStyle-Width="1%" HeaderStyle-Width="1%" ImageUrl="delete.gif" Text="Delete" />
<telerik:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="edit.gif" EditText="Edit" UniqueName="EditCommandColumn" ItemStyle-Width="1%" ItemStyle-Wrap="false"> </telerik:GridEditCommandColumn>
.......
All of these addons are displayed in Excel now. Please advise
Unfortunately I could not reproduce the issue on the live site. It will be best if you can send us a simple running project (incl. CSS, images, skins, DB backup if needed and so on) demonstrating the problem (and step-by-step instructions on doing so). In that way we can reproduce the problem you are facing on our side and provide a solution.
Best wishes,
Pavlina
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.
To avoid duplicate posts, we will continue our communication in the support ticket that you have opened on the matter.
Greetings,
Pavlina
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.