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

Self hierarchical grid not exporting the detail table contents if it is collapsed

7 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
Bharathwajan Venkatanarayanan asked on 26 Sep 2009, 10:34 AM

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

Sort by
0
Pavlina
Telerik team
answered on 26 Sep 2009, 03:58 PM
Hi Bharathwajan,

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.
0
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
answered on 29 Sep 2009, 09:17 AM
Hi Pavlina,

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
0
Pavlina
Telerik team
answered on 29 Sep 2009, 01:45 PM
Hello 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.
0
spt
Top achievements
Rank 1
answered on 11 Nov 2009, 10:39 AM
I have a problems of exporting to Excel of self-hierarchical grid.
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

 

 

 

 

 

 

 

0
Pavlina
Telerik team
answered on 12 Nov 2009, 03:50 PM
Hello Igor,

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.
0
spt
Top achievements
Rank 1
answered on 13 Nov 2009, 10:28 AM
Ok, I have sent you support ticket. Thanks.
0
Pavlina
Telerik team
answered on 17 Nov 2009, 03:55 PM
Hi,

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.
Tags
Grid
Asked by
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
spt
Top achievements
Rank 1
Share this question
or