I have a RadGrid on my page which contains a NestedViewTemplate. Every level of the hierarchy has its LoadMode set to "ServerOnDemand".
When I attempt to export data to Excel, only the top-level data is being exported. Here is the code I use to export.
If every level is set to "ServerBind", then I am able to get an export of all the data. However, I would prefer to use "ServerOnDemand" as it is quicker to navigate prior to export.
Is there any way to get all the data to export using "ServerOnDemand"?
Thanks,
Brian Furner
| <telerik:RadGrid ID="rgMonthly" runat="server" GridLines="None" DataSourceID="odsAcctsByPI" |
| OnColumnCreated="rgMonthly_ColumnCreated" OnItemDataBound="rgMonthly_ItemDataBound" |
| OnPreRender="rgMonthly_PreRender" AutoGenerateColumns="true"> |
| <MasterTableView DataSourceID="odsAcctsByPI" DataKeyNames="SlAcct6Num" HierarchyLoadMode="ServerOnDemand" |
| EnableColumnsViewState="False"> |
| <NestedViewSettings DataSourceID="odsGroupsByAcct"> |
| <ParentTableRelation> |
| <telerik:GridRelationFields DetailKeyField="SlAcct6Num" MasterKeyField="SlAcct6Num" /> |
| </ParentTableRelation> |
| </NestedViewSettings> |
| <NestedViewTemplate> |
| <telerik:RadGrid ID="rgSubs" runat="server" GridLines="None" DataSourceID="odsGroupsByAcct" |
| AutoGenerateColumns="true" OnColumnCreated="rgSubs_ColumnCreated" OnItemDataBound="rgSubs_ItemDataBound"> |
| <MasterTableView DataSourceID="odsGroupsByAcct" DataKeyNames="SlAcct6Num,GroupID" |
| HierarchyLoadMode="ServerOnDemand" EnableColumnsViewState="False"> |
| <DetailTables> |
| <telerik:GridTableView Width="100%" runat="server" HierarchyLoadMode="ServerOnDemand" |
| AutoGenerateColumns="true" EnableColumnsViewState="False" DataKeyNames="SlAcct6Num,GroupID" |
| DataSourceID="odsSubAcctsByGroup"> |
| <ParentTableRelation> |
| <telerik:GridRelationFields DetailKeyField="GroupID" MasterKeyField="GroupID" /> |
| <telerik:GridRelationFields DetailKeyField="SlAcct6Num" MasterKeyField="SlAcct6Num" /> |
| </ParentTableRelation> |
| </telerik:GridTableView> |
| </DetailTables> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </NestedViewTemplate> |
| </MasterTableView> |
| </telerik:RadGrid> |
When I attempt to export data to Excel, only the top-level data is being exported. Here is the code I use to export.
| protected void btnExcel_Click(object sender, EventArgs e) |
| { |
| rgMonthly.ExportSettings.OpenInNewWindow = true; |
| rgMonthly.ExportSettings.ExportOnlyData = true; |
| rgMonthly.ExportSettings.IgnorePaging = true; |
| foreach (GridDataItem gi in rgMonthly.MasterTableView.Items) |
| { |
| gi.Expanded = true; |
| if (gi.HasChildItems) |
| { |
| RadGrid rgSubs = (RadGrid)gi.ChildItem.NestedViewCell.Controls[0].Controls[1]; |
| foreach (GridDataItem gilvl3 in rgSubs.MasterTableView.Items) |
| { |
| if (!gilvl3.KeyValues.Contains("-1")) |
| { |
| gilvl3.Expanded = true; |
| } |
| } |
| } |
| } |
| rgMonthly.MasterTableView.ExportToExcel(); |
| } |
If every level is set to "ServerBind", then I am able to get an export of all the data. However, I would prefer to use "ServerOnDemand" as it is quicker to navigate prior to export.
Is there any way to get all the data to export using "ServerOnDemand"?
Thanks,
Brian Furner