Sebastian Talamoni
Top achievements
Rank 1
Sebastian Talamoni
asked on 01 Apr 2008, 09:38 PM
Hi,
I'm using the export to pdf feature in some simple grids with no problem.
In 1 grid I am using a <DetailsTables> structure and in that case I get the following exception if i try to export to pdf:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Telerik.Web.Apoc.Fo.Flow.TableRow.CellArray.GetNextFreeCell(Int32 colNum)
at Telerik.Web.Apoc.Fo.Flow.TableRow.InitCellArray()
I am newby to Telerik, is there something I should know when using the export with Details Tables?
Note: Clearing the DetailTables collection just prior to export works but it's not the desired output since i would like to "see" my child table in the output pdf.
Example code:
pGrid.MasterTableView.DetailTables.Clear();
pGrid.MasterTableView.ExportToPdf();
I'm using the export to pdf feature in some simple grids with no problem.
In 1 grid I am using a <DetailsTables> structure and in that case I get the following exception if i try to export to pdf:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Telerik.Web.Apoc.Fo.Flow.TableRow.CellArray.GetNextFreeCell(Int32 colNum)
at Telerik.Web.Apoc.Fo.Flow.TableRow.InitCellArray()
I am newby to Telerik, is there something I should know when using the export with Details Tables?
Note: Clearing the DetailTables collection just prior to export works but it's not the desired output since i would like to "see" my child table in the output pdf.
Example code:
pGrid.MasterTableView.DetailTables.Clear();
pGrid.MasterTableView.ExportToPdf();
4 Answers, 1 is accepted
0
Hello Sebastian,
Please check if you have ExportSettings.IgnorePaging set to true. If this is the case you can workaround the problem similar to the attached project.
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Please check if you have ExportSettings.IgnorePaging set to true. If this is the case you can workaround the problem similar to the attached project.
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Sebastian Talamoni
Top achievements
Rank 1
answered on 02 Apr 2008, 08:24 AM
Vlad,
Thanks for so prompt reply.
I've set my project settings to match the ones in the given example and it still gives me exactly the same error.
Important: commenting the "ignore paging" works. So you are correct about the fact that it has something to do with it.
I've changed to use excel (instead of PDF) and also works correctly independently of the IgnorePaging value.
I am now going to post some code details:
private void PrintCurrentGrid()
{
// important note setting IgnorePaging = false fixes the error but off course is not the desired result.
RadGrid1.ExportSettings.IgnorePaging = true;
RadGrid1.ExportSettings.OpenInNewWindow = true;
RadGrid1.ExportSettings.ExportOnlyData = true;
RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
RadGrid1.Rebind();
RadGrid1.MasterTableView.ExportToPdf();
The ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="ObjectDataSource1" Width="100%"
AllowFilteringByColumn="True"
AllowPaging="True" PageSize=5
AllowSorting="True" AutoGenerateColumns="False"
Skin="WebBlue"
OnDeleteCommand="RadGrid1_DeleteCommand"
OnItemCommand="RadGrid1_ItemCommand"
OnDetailTableDataBind="RadGrid1_DetailTableDataBind">
<MasterTableView CurrentResetPageIndexAction="SetPageIndexToFirst" Dir="LTR" Frame="Border"
DataKeyNames="Offerte_id" HierarchyDefaultExpanded="true"
TableLayout="Auto" CommandItemDisplay="Top" DataSourceID="ObjectDataSource1">
<RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
Visible="False">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
Visible="False" Resizable="False">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType">
</EditColumn>
</EditFormSettings>
<CommandItemTemplate>
<asp:LinkButton ID="LinkButtonNew" runat="server" CommandName="InitInsert"
PostBackUrl="OfferteNew.aspx">
<img style="border:0px" alt="" src="../App_Themes/GenWiseTheme/insert.gif" />
Nieuwe Offerte
</asp:LinkButton>
<asp:LinkButton ID="BtnPrint" runat="server" CommandName="Print">
<img style="border:0px" alt="" src="../App_Themes/GenWiseTheme/printer.png" />
Afdruken
</asp:LinkButton>
<asp:LinkButton ID="BtnPrintGrid" runat="server" CommandName="PrintGrid">
<img style="border:0px" alt="" src="../App_Themes/GenWiseTheme/printer.png" />
Lijst
</asp:LinkButton>
<asp:LinkButton ID="BtnDelete" runat="server" CommandName="Delete">
<img style="border:0px" alt="" src="../App_Themes/GenWiseTheme/Delete.gif" />
Delete Selected
</asp:LinkButton>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="NieuweWerkbon">
<img style="border:0px" alt="" src="../App_Themes/GenWiseTheme/Insert.gif" />
Maak Werkbon
</asp:LinkButton>
</CommandItemTemplate>
<Columns>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Offerte_id"
DataType="System.Decimal" ForceExtractValue="None"
HeaderText="Offerte ID" SortExpression="Offerte_id" UniqueName="Offerte_id">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Relatie_id"
DataType="System.Decimal" FilterListOptions="VaryByDataType" ForceExtractValue="None"
HeaderText="Relatie_id" SortExpression="Relatie_id" UniqueName="Relatie_id">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Relatie" AllowFiltering="false" Resizable="false">
<ItemStyle Wrap="false" />
<ItemTemplate>
<asp:LinkButton runat="server" ID="RelatieLink"
CommandName="GoToCustomer" CommandArgument='<%# Eval("Offerte_id") %>'
Text='<%# Eval("Relatie.bEDRIJFSNaam") %>' >
</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Levertijd"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Levertijd"
ReadOnly="True" SortExpression="Levertijd" UniqueName="Levertijd">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="EqualTo" DataField="Betaling"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Betaling"
ReadOnly="True" SortExpression="Betaling" UniqueName="Betaling">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Aanmaakdatum"
DataFormatString="{0:d}"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Levering"
SortExpression="Aanmaakdatum" UniqueName="Aanmaakdatum">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Gereedschapskosten"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Ordernummer"
SortExpression="Gereedschapskosten" UniqueName="Gereedschapskosten">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Status_id" DataType="System.Decimal"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Status_id"
SortExpression="Status_id" UniqueName="Status_id">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Status.Omschrijving"
DataType="System.String" FilterListOptions="VaryByDataType" ForceExtractValue="None"
HeaderText="Status" SortExpression="Status.Omschrijving" UniqueName="Status.Omschrijving">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Bedrag"
DataType="System.Single" FilterListOptions="VaryByDataType" ForceExtractValue="None"
HeaderText="Bedrag" ReadOnly="True" SortExpression="Bedrag"
DataFormatString="{0:c}"
UniqueName="Bedrag">
</telerik:GridBoundColumn>
</Columns>
<DetailTables>
<telerik:GridTableView Width="100%" runat="server" Name="Offerte_regel">
<Columns>
<telerik:GridBoundColumn AllowFiltering="false" AllowSorting="false"
DataField="Aantal" DataType="System.Decimal"
HeaderText="Aantal" UniqueName="Aantal">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowFiltering="false" AllowSorting="false"
DataField="Artikel_id" DataType="System.Decimal"
HeaderText="Artikel ID" UniqueName="Artikel_id">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowFiltering="false" AllowSorting="false"
DataField="Artikel.Naam" DataType="System.String"
HeaderText="Artikel Naam" UniqueName="Artikel.Naam">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowFiltering="false" AllowSorting="false"
DataField="StukPrijs" DataType="System.Decimal" DataFormatString="{0:c}"
HeaderText="StukPrijs" UniqueName="StukPrijs">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowFiltering="false" AllowSorting="false"
DataField="Bedrag" DataType="System.Decimal" DataFormatString="{0:c}"
HeaderText="Bedrag" UniqueName="Bedrag">
</telerik:GridBoundColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
</MasterTableView>
<ExportSettings ExportOnlyData="True" IgnorePaging="false" OpenInNewWindow="True">
</ExportSettings>
<ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
<Selecting AllowRowSelect="True">
</Selecting>
</ClientSettings>
</telerik:RadGrid>
Thanks for so prompt reply.
I've set my project settings to match the ones in the given example and it still gives me exactly the same error.
Important: commenting the "ignore paging" works. So you are correct about the fact that it has something to do with it.
I've changed to use excel (instead of PDF) and also works correctly independently of the IgnorePaging value.
I am now going to post some code details:
private void PrintCurrentGrid()
{
// important note setting IgnorePaging = false fixes the error but off course is not the desired result.
RadGrid1.ExportSettings.IgnorePaging = true;
RadGrid1.ExportSettings.OpenInNewWindow = true;
RadGrid1.ExportSettings.ExportOnlyData = true;
RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
RadGrid1.Rebind();
RadGrid1.MasterTableView.ExportToPdf();
The ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="ObjectDataSource1" Width="100%"
AllowFilteringByColumn="True"
AllowPaging="True" PageSize=5
AllowSorting="True" AutoGenerateColumns="False"
Skin="WebBlue"
OnDeleteCommand="RadGrid1_DeleteCommand"
OnItemCommand="RadGrid1_ItemCommand"
OnDetailTableDataBind="RadGrid1_DetailTableDataBind">
<MasterTableView CurrentResetPageIndexAction="SetPageIndexToFirst" Dir="LTR" Frame="Border"
DataKeyNames="Offerte_id" HierarchyDefaultExpanded="true"
TableLayout="Auto" CommandItemDisplay="Top" DataSourceID="ObjectDataSource1">
<RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
Visible="False">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
Visible="False" Resizable="False">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType">
</EditColumn>
</EditFormSettings>
<CommandItemTemplate>
<asp:LinkButton ID="LinkButtonNew" runat="server" CommandName="InitInsert"
PostBackUrl="OfferteNew.aspx">
<img style="border:0px" alt="" src="../App_Themes/GenWiseTheme/insert.gif" />
Nieuwe Offerte
</asp:LinkButton>
<asp:LinkButton ID="BtnPrint" runat="server" CommandName="Print">
<img style="border:0px" alt="" src="../App_Themes/GenWiseTheme/printer.png" />
Afdruken
</asp:LinkButton>
<asp:LinkButton ID="BtnPrintGrid" runat="server" CommandName="PrintGrid">
<img style="border:0px" alt="" src="../App_Themes/GenWiseTheme/printer.png" />
Lijst
</asp:LinkButton>
<asp:LinkButton ID="BtnDelete" runat="server" CommandName="Delete">
<img style="border:0px" alt="" src="../App_Themes/GenWiseTheme/Delete.gif" />
Delete Selected
</asp:LinkButton>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="NieuweWerkbon">
<img style="border:0px" alt="" src="../App_Themes/GenWiseTheme/Insert.gif" />
Maak Werkbon
</asp:LinkButton>
</CommandItemTemplate>
<Columns>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Offerte_id"
DataType="System.Decimal" ForceExtractValue="None"
HeaderText="Offerte ID" SortExpression="Offerte_id" UniqueName="Offerte_id">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Relatie_id"
DataType="System.Decimal" FilterListOptions="VaryByDataType" ForceExtractValue="None"
HeaderText="Relatie_id" SortExpression="Relatie_id" UniqueName="Relatie_id">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Relatie" AllowFiltering="false" Resizable="false">
<ItemStyle Wrap="false" />
<ItemTemplate>
<asp:LinkButton runat="server" ID="RelatieLink"
CommandName="GoToCustomer" CommandArgument='<%# Eval("Offerte_id") %>'
Text='<%# Eval("Relatie.bEDRIJFSNaam") %>' >
</asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Levertijd"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Levertijd"
ReadOnly="True" SortExpression="Levertijd" UniqueName="Levertijd">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="EqualTo" DataField="Betaling"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Betaling"
ReadOnly="True" SortExpression="Betaling" UniqueName="Betaling">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Aanmaakdatum"
DataFormatString="{0:d}"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Levering"
SortExpression="Aanmaakdatum" UniqueName="Aanmaakdatum">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Gereedschapskosten"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Ordernummer"
SortExpression="Gereedschapskosten" UniqueName="Gereedschapskosten">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Status_id" DataType="System.Decimal"
FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Status_id"
SortExpression="Status_id" UniqueName="Status_id">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Status.Omschrijving"
DataType="System.String" FilterListOptions="VaryByDataType" ForceExtractValue="None"
HeaderText="Status" SortExpression="Status.Omschrijving" UniqueName="Status.Omschrijving">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Bedrag"
DataType="System.Single" FilterListOptions="VaryByDataType" ForceExtractValue="None"
HeaderText="Bedrag" ReadOnly="True" SortExpression="Bedrag"
DataFormatString="{0:c}"
UniqueName="Bedrag">
</telerik:GridBoundColumn>
</Columns>
<DetailTables>
<telerik:GridTableView Width="100%" runat="server" Name="Offerte_regel">
<Columns>
<telerik:GridBoundColumn AllowFiltering="false" AllowSorting="false"
DataField="Aantal" DataType="System.Decimal"
HeaderText="Aantal" UniqueName="Aantal">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowFiltering="false" AllowSorting="false"
DataField="Artikel_id" DataType="System.Decimal"
HeaderText="Artikel ID" UniqueName="Artikel_id">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowFiltering="false" AllowSorting="false"
DataField="Artikel.Naam" DataType="System.String"
HeaderText="Artikel Naam" UniqueName="Artikel.Naam">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowFiltering="false" AllowSorting="false"
DataField="StukPrijs" DataType="System.Decimal" DataFormatString="{0:c}"
HeaderText="StukPrijs" UniqueName="StukPrijs">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn AllowFiltering="false" AllowSorting="false"
DataField="Bedrag" DataType="System.Decimal" DataFormatString="{0:c}"
HeaderText="Bedrag" UniqueName="Bedrag">
</telerik:GridBoundColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
</MasterTableView>
<ExportSettings ExportOnlyData="True" IgnorePaging="false" OpenInNewWindow="True">
</ExportSettings>
<ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
<Selecting AllowRowSelect="True">
</Selecting>
</ClientSettings>
</telerik:RadGrid>
0
Accepted
Hi Sebastian,
Thank you for posting your code.
Can you try to modify you PrintCurrentGrid() method as suggested below and let us know if it works for you.
Best regards,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for posting your code.
Can you try to modify you PrintCurrentGrid() method as suggested below and let us know if it works for you.
| private void PrintCurrentGrid() |
| { |
| RadGrid1.ExportSettings.OpenInNewWindow = true; |
| RadGrid1.ExportSettings.ExportOnlyData = true; |
| RadGrid1.MasterTableView.HierarchyDefaultExpanded = true; |
| RadGrid1.AllowPaging = false; |
| RadGrid1.Rebind(); //instead of RadGrid1.ExportSettings.IgnorePaging = true; |
| RadGrid1.MasterTableView.ExportToPdf(); |
| } |
Best regards,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Sebastian Talamoni
Top achievements
Rank 1
answered on 07 Apr 2008, 01:13 PM
Yes!
That did the trick.
Thanks.
That did the trick.
Thanks.
