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

[Solved] pdf hierarchical grids exporting - no child data got

4 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
flavio raimondi
Top achievements
Rank 1
flavio raimondi asked on 03 Sep 2009, 01:12 PM
hi,

I am facing a problem in exporting hierarchical grids to pdf: the generated doc doesn't include the data from the child grid.
Here is the scenario:
. 2 grids with "master-datails" relationship (<ParentTableRelation> set)
. expand the child grid, ok all data is there
. push the button that trigger the parentTable.MasterTableView.ExportToPdf() method, ok
. get the windows with the exported data in the right format, pagesize, etc.  but WITHOUT the expanded data from the child table.
What am I missing?
Thanks in advance for any help.
Flavio

Here is the code:
--- aspx----------------------------
<telerik:RadGrid ID="grwJobNTasks" runat="server"
  Width="100%"
  ShowStatusBar="true"
        AutoGenerateColumns="False"
        AllowSorting="True"
        AllowMultiRowSelection="False"
        AllowPaging="True"
  GridLines="None"
  meta:resourcekey="grwJobNTasksResource"
     EnableViewState="True"
  OnPdfExporting="grwJobNTasks_PdfExporting"
  OnDetailTableDataBind="grwJobNTasks_DetailTableDataBind"
  OnNeedDataSource="grwJobNTasks_NeedDataSource"
  SettingsChangedCallBack="CallBackFn"
        >
        <ExportSettings IgnorePaging="true" OpenInNewWindow="true">
            <Pdf PageHeight="210mm" PageWidth="297mm" PageTitle="Job 'n Tasks" AllowPrinting="true" />
        </ExportSettings>    
        <MasterTableView Width="100%" DataKeyNames="JobId" AllowMultiColumnSorting="True"
   HierarchyLoadMode="ServerOnDemand" CommandItemDisplay="None">
   <DetailTables>
                <telerik:GridTableView DataKeyNames="JobTaskId" Name="JobTasks" AllowPaging="true" ShowFooter="true"
     runat="server" Caption="Job's tasks" Width="100%" CommandItemDisplay="None">
     <ParentTableRelation>
      <telerik:GridRelationFields DetailKeyField="OwnerId" MasterKeyField="JobId" />
     </ParentTableRelation>
     <Columns>
      <telerik:GridBoundColumn DataField="TTGCode" HeaderText="TTG Code" UniqueName="TTGCode" />
      <telerik:GridTemplateColumn UniqueName="SuccessTemplateColumn" HeaderText="Result">
       <ItemTemplate>
        <asp:Label runat="server" ID="SuccessColumn"  Text='<%# GetSuccessLabel(Eval("Success")) %>'/>
       </ItemTemplate>
      </telerik:GridTemplateColumn>
      <telerik:GridBoundColumn DataField="StepError" HeaderText="Step Error" UniqueName="StepError" />
      <telerik:GridBoundColumn DataField="ErrorDesc" HeaderText="Error Description" UniqueName="ErrorDesc" />
      <telerik:GridTemplateColumn UniqueName="StartingTimeTemplateColumn" HeaderText="Starting Time">
       <ItemTemplate>
        <asp:Label runat="server" ID="StartingTimeColumn"  Text='<%# GetDateTimeLabel(Eval("StartingTime")) %>'/>
       </ItemTemplate>
      </telerik:GridTemplateColumn>
     </Columns>
    </telerik:GridTableView>
   </DetailTables>
   <Columns>
    <telerik:GridTemplateColumn UniqueName="JobTypeTemplateColumn" HeaderText="Job Type">
     <ItemTemplate>
      <asp:Label runat="server" ID="JobTypeColumn" Text='<%# JobTypes.Value((int)Eval("JobType")) %>'/>
     </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridBoundColumn DataField="StartDateTime" HeaderText="Schedule Time" UniqueName="StartDateTime"
     DataType="System.DateTime" DataFormatString="{0:G}" HtmlEncode="False" />
    <telerik:GridTemplateColumn UniqueName="StatusIdTemplateColumn" HeaderText="Result">
     <ItemTemplate>
      <asp:Label runat="server" ID="StatusIdColumn"  Text='<%# JobStatuses.Value((int)Eval("StatusId")) %>'/>
     </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn UniqueName="InsertByTemplateColumn" HeaderText="Insert By">
     <ItemTemplate>
      <asp:Label runat="server" ID="InsertByColumn"  Text='<%# GetUserDesc(Eval("InsertBy")) %>'/>
     </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridBoundColumn DataField="InsertDate" HeaderText="Insert Date" UniqueName="InsertDate"
     DataType="System.DateTime" DataFormatString="{0:G}" HtmlEncode="False" />
   </Columns>
   <NoRecordsTemplate>
    <%=(string)this.GetLocalResourceObject("NoData")%>
   </NoRecordsTemplate>
  </MasterTableView>
 </telerik:RadGrid>
--- c# ------------------------------

 protected void grwJobNTasks_Print(Object sender, EventArgs e)
 {

  grwJobNTasks.MasterTableView.ExportToPdf();
 } 

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 03 Sep 2009, 08:15 PM
Hello Flavio,

I recommend you either disable IgnorePaging or set HierarchyDefaultExpanded="true"
 <ExportSettings IgnorePaging="false" /> 

 <MasterTableView HierarchyDefaultExpanded="true" .... 

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
flavio raimondi
Top achievements
Rank 1
answered on 08 Sep 2009, 09:02 AM

Thanks Daniel for your recommendations.

I tried them out, but I am having troubles again:
1. If I use the 
HierarchyDefaultExpanded="true"  I get all the details expanded, and this is NON what I need

2. Anyway, if I try to generate the pdf (with the IgnorePaging enabled or not) I am getting now an XmlException - the character "*" cannot be used in a name -, preventing me from seeing the results; I think this problem is another matter, am I right? Can you give me any direction on how to solve it?

Thank you

Flavio

0
Daniel
Telerik team
answered on 08 Sep 2009, 03:02 PM
Hello Flavio,

1) You can either persist the expanded items or avoid using IgnorePaging as mentioned below

2) The problem is that RadComboBox (in the GridPagerItem) uses special CSS approach that is incompatible with the PDF XSLT transformation. Again, there are two ways to sidestep this -> set ExportOnlyData="true" or hide the unwanted control programmatically:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    if (e.Item is GridPagerItem && isExport) 
    { 
        //remove PageSize combo   
        e.Item.FindControl("PageSizeComboBox").Parent.Visible = false
    } 

I hope this helps.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
flavio raimondi
Top achievements
Rank 1
answered on 09 Sep 2009, 07:54 AM

Hi Daniel,

 

Thanks to your suggestions, I can now do something like I wanted to (I can now get a PDF with the details grid expanded, but only of the page currently shown, meanwhile I hoped to get all the master data with just the details expanded by the user);  so I had to:

1.       avoid using IgnorePaging

2.       hide the PageSize combo; I did it in the eventHandler_ItemCreated, as you suggested, but the eventHandler_ItemCreated didn’t get triggered during pdf rendering, so I did it during normal page rendering – at the first eventHandler_ItemCreated call -- (cutting off this feature...)

 

Thank you.

Flavio

 

Tags
Grid
Asked by
flavio raimondi
Top achievements
Rank 1
Answers by
Daniel
Telerik team
flavio raimondi
Top achievements
Rank 1
Share this question
or