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

Export Multi-Level Hierarchy RadGrid

8 Answers 288 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zach
Top achievements
Rank 1
Zach asked on 03 Jun 2009, 02:05 PM
After looking and looking at posts, either this is very easy or it's very difficult.  Regardless, just wanted to see if anyone has a solution.

I have a hiearchical radgrid with 4 detail table levels.  The functionality works great.  Does everything I want it to.  My one problem that is holding me back is the exporting.  I am basically looking at exporting whatever is expanded at the time the export button is clicked.  I know that the command line RadGrid.MasterTableView.ExportToExcel() will just export the master table.  I tried the .HierarchyDefaultExpanded = true but that expands every row and I only want the rows expanded by the user.

This demo is similar to what I have.

I tried looping through each row in the mastertableview to capture if it is expanded, but then I can't figure out a way to go through and expand those rows before it exports.  If I can figure out this, then it should be fairly easy to go through each detail table to do the same.

Any input is appreciated.  If you need me to be more specific, let me know.

Zach

8 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 08 Jun 2009, 12:12 PM
Hello Zach,

For your convenience I attached simple demo which illustrates how to attain the desired functionality.
Another possible approach is set ExportOnlyData and IgnorePaging properties to false.

Let me know if you need more information.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Zach
Top achievements
Rank 1
answered on 08 Jun 2009, 03:43 PM
Daniel,

Setting IgnorePaging to false did the trick.  I figured it was something easy.

Thanks!
Zach

0
John
Top achievements
Rank 2
answered on 20 Jul 2009, 02:14 PM
I am trying to use this example with a RadGrid loaded in a rad ajax panel.  What changes would I need to make it work?

Thanks,

John
0
Daniel
Telerik team
answered on 20 Jul 2009, 02:44 PM
Hello John,

Please examine the following links:
Export from ajaxified grid
Export from ajaxified grid code-library
Exclude controls from ajaxifying

Let us know if you need more information.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Yuvraj
Top achievements
Rank 1
answered on 19 Aug 2009, 12:22 PM
I am also looking the Same sort of solution What I have done is as below with my issue

1. Created Hirarchy structure for grid (Master -Detail and Sub Detail tables)  from code behind (Dynamically Created Grid) and loded Master Table by default
2. on Click of Expand i.e + icon I load the detail table data in to it because i am working on huge and all statistical data runtime calculation.
3. All the Stuff work fine for the grid but issue is when I export the grid from following code

RadGrid

 

radGrid1 = PlaceHolder1.FindControl("StatisticsGrid1") as RadGrid;  

radGrid1.ExportSettings.OpenInNewWindow =

true;

 

 

 radGrid1.ExportSettings.ExportOnlyData =

true;

 

 

 radGrid1.ExportSettings.IgnorePaging =

true

 

 

 

 

 

//radGrid1.ExportSettings.Pdf.PageWidth = Unit.Parse("320mm"); 

 

//foreach (GridItem item in radGrid1.MasterTableView.Items)

 

 

 

// if (item.ItemIndex == 0)

 

 

 

// item.Expanded = true;

 

 

 

// radGrid1.MasterTableView.ExportToExcel();

 

radGrid1.MasterTableView.ExportToPdf();

Only the Master Table Grid get exported and not the Detail table get exported which is expanded by the User.
4. Previously I have done the same with the radgrid which is i have included in the .aspx page but at this time Grid is Dynamic and cant able to export the Exact look of the Grid which is expanded by the User. Also need to export the Style of the Grid along with it.

What would be the solution?

0
Yuvraj
Top achievements
Rank 1
answered on 21 Aug 2009, 10:38 AM
I tried another solution by Rendering the Radgrid object. I also face problem while render so i remove the Button controls from radgrid and render it to HtmlTextWriter, but when i do any change (removing Exapand Button i.e +) to the new object of radgrid it get reflected to the Orignal Radgrid in the web form and the "+" ExpandCollaps button go away from the Orignal radgrid. I dont want the orignal Radgrid affected any change done to the radgrid new Variable/Object. How to solve this or Previous issue?
0
Daniel
Telerik team
answered on 24 Aug 2009, 06:28 AM
Hello Yuvraj,

I can suggest you two ways to avoid this:
- set IgnorePaging = "false"
- persist the expanded items

IgnorePaging="true" will rebind RadGrid before export and thus will collapse all expanded items.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Yuvraj
Top achievements
Rank 1
answered on 24 Aug 2009, 07:28 AM

:) Thanks a lot, I ve missed this and previously I make it true. Also I ve Rebinded my grid object in main class so i remove it in to conditional logic
And  set IgnorePaging = "false" Solved my problem Below is my new Code and it work for my requirement.

private void ExportGridToExcelPdf(RadGrid grid)
        {
            RadGrid radGrid1=grid; 
            radGrid1.ExportSettings.OpenInNewWindow=true;
            radGrid1.ExportSettings.ExportOnlyData=true;
            radGrid1.ExportSettings.IgnorePaging=false;            
            //foreach (GridItem item in radGrid1.MasterTableView.Items)
            //    if (item.ItemIndex == 0)
            //        item.Expanded = true;
           radGrid1.MasterTableView.ExportToExcel();
            //radGrid1.MasterTableView.ExportToPdf();
        }

Tags
Grid
Asked by
Zach
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Zach
Top achievements
Rank 1
John
Top achievements
Rank 2
Yuvraj
Top achievements
Rank 1
Share this question
or