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
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.
Setting IgnorePaging to false did the trick. I figured it was something easy.
Thanks!
Zach
Thanks,
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.
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?
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.
:) 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();
}