I'm running ASP.NET AJAX Q3 2009 and have a grid with a detail table that I need to export.
The master table is populated through the NeedDataSource event and the detail table is populated through the DetailTableDataBind event.
When exporting, I am unable to include the records from the detail table. here is the code for the grid on the aspx page
<telerik:RadGrid |
ID="rdgCorrespondence" |
runat="server" |
AllowFilteringByColumn="True" |
AllowPaging="True" |
AllowSorting="True" |
AutoGenerateColumns="False" |
GridLines="None" |
OnNeedDataSource="rdgCorrespondence_NeedDataSource" |
OnDetailTableDataBind="rdgCorrespondence_DetailTableDataBind" |
OnItemDataBound="rdgCorrespondence_ItemDataBound" |
OnInsertCommand="rdgCorrespondence_InsertCommand" |
OnUpdateCommand="rdgCorrespondence_UpdateCommand" |
onitemcommand="rdgCorrespondence_ItemCommand"> |
<MasterTableView |
CommandItemDisplay="Top" |
DataKeyNames="CorrespondenceID" |
Name="Correspondences" |
Width="100%" |
HierarchyLoadMode="ServerBind"> |
<CommandItemSettings |
ShowExportToExcelButton="true" |
/> |
<EditFormSettings> |
<EditColumn UniqueName="EditCommandColumn1"> |
</EditColumn> |
</EditFormSettings> |
<HeaderStyle HorizontalAlign="Center" /> |
<ExpandCollapseColumn Visible="True"> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridEditCommandColumn ButtonType="ImageButton"> |
</telerik:GridEditCommandColumn> |
<telerik:GridBoundColumn DataField="CorrespondenceID" HeaderText="ID" UniqueName="CorrespondenceID" |
ReadOnly="true" FilterControlWidth="20" ItemStyle-Width="25" ItemStyle-HorizontalAlign="Right" ForceExtractValue="Always"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn UniqueName="TypeName" HeaderText="Type" DataField="TypeName"> |
</telerik:GridBoundColumn> |
</Columns> |
<DetailTables> |
<telerik:GridTableView |
DataKeyNames="CorrespondenceNoteID" |
CommandItemDisplay="Top" |
Name="CorrespondenceNotes" |
Width="100%" |
AllowFilteringByColumn="false" |
BorderColor="#fff" |
HierarchyLoadMode="Client"> |
<ParentTableRelation> |
<telerik:GridRelationFields DetailKeyField="CorrespondenceID" MasterKeyField="CorrespondenceID" /> |
</ParentTableRelation> |
<Columns> |
<telerik:GridEditCommandColumn ButtonType="ImageButton"> |
</telerik:GridEditCommandColumn> |
<telerik:GridBoundColumn DataField="CorrespondenceNoteID" HeaderText="Note ID" UniqueName="CorrespondenceNoteID" |
ReadOnly="true"> |
</telerik:GridBoundColumn> |
<telerik:GridDateTimeColumn DataField="DateOfNote" HeaderText="Date" UniqueName="DateOfNote"> |
</telerik:GridDateTimeColumn> |
<telerik:GridBoundColumn DataField="Note" HeaderText="Comment" UniqueName="Note"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="CorrespondenceID" HeaderText="Correspondence ID" |
UniqueName="CorrespondenceID" ReadOnly="true" Display="false"> |
</telerik:GridBoundColumn> |
</Columns> |
<SortExpressions> |
<telerik:GridSortExpression FieldName="DateOfNote" SortOrder="Descending" /> |
</SortExpressions> |
</telerik:GridTableView> |
</DetailTables> |
</MasterTableView> |
</telerik:RadGrid> |
and here is my excel call:
protected void rdgCorrespondence_ItemCommand(object source, GridCommandEventArgs e) |
{ |
string fileName = "Correspondences"; |
if (e.CommandName = RadGrid.ExportToExcelCommandName) |
{ |
grid.ExportSettings.FileName = fileName; |
grid.ExportSettings.HideStructureColumns = true; |
grid.ExportSettings.IgnorePaging = true; |
grid.ExportSettings.OpenInNewWindow = true; |
grid.ExportSettings.ExportOnlyData = true; |
grid.MasterTableView.ExportToExcel(); |
} |
} |
Is the current implementation of the radgrid not support this type of export?