The MindFusion Forums
MindFusion.Reporting >> WPF >> The empty DataRange can NOT be exported to PDF
https://mindfusion.eu/Forum/YaBB.pl?num=1368524680

Message started by luolishuang on May 14th, 2013 at 9:44am

Title: The empty DataRange can NOT be exported to PDF
Post by luolishuang on May 14th, 2013 at 9:44am
The empty DataRange can NOT be exported to PDF

any solution??

Title: Re: The empty DataRange can NOT be exported to PDF
Post by Meppy on May 14th, 2013 at 11:09am
Hi,

Currently empty data ranges are not displayed in reports. You can set DataRange.Repeat to 1 for the data range to force it to have one instance.

Let me know if this helps.

Regards,
Meppy

Title: Re: The empty DataRange can NOT be exported to PDF
Post by luolishuang on May 15th, 2013 at 3:25am
but I wanna to control the datarange to display or not by condition.

any solution?

Title: Re: The empty DataRange can NOT be exported to PDF
Post by Meppy on May 15th, 2013 at 5:33am
Try setting DataRange.Repeat to 1 for the empty data ranges that you want to be visible. Make sure that DataRange.DataSource is set to null in this case. You can also set Repeat in the QueryDetails event handler for nested data ranges. In this case set QueryDetailsEventArgs.Details to null.

Regards,
Meppy

Title: Re: The empty DataRange can NOT be exported to PDF
Post by luolishuang on May 15th, 2013 at 6:43am

Meppy wrote on May 15th, 2013 at 5:33am:
Try setting DataRange.Repeat to 1 for the empty data ranges that you want to be visible. Make sure that DataRange.DataSource is set to null in this case. You can also set Repeat in the QueryDetails event handler for nested data ranges. In this case set QueryDetailsEventArgs.Details to null.

Regards,
Meppy


Hi,

This still display the DataRange, but I wanna to control the DataRange invisible.

any solution?

Title: Re: The empty DataRange can NOT be exported to PDF
Post by Meppy on May 15th, 2013 at 8:12am
Can you provide me with a sample with your report and specify which data ranges in this report you want to show or hide?

Regards,
Meppy

Title: Re: The empty DataRange can NOT be exported to PDF
Post by luolishuang on May 15th, 2013 at 9:01am

Meppy wrote on May 15th, 2013 at 8:12am:
Can you provide me with a sample with your report and specify which data ranges in this report you want to show or hide?

Regards,
Meppy


Hi, the xaml sample code below:

Code (html):

            <r:DataRange DataSource="{Binding QuestionTable}" Size="100%,100">
                <r:DataRange.ItemTemplate >
                    <DataTemplate >
                        <r:ItemContainer >
                            <r:DataRange  Name="AnswerList" Location="0%,60" Size="100%,20">
                                <r:DataRange.ItemTemplate>
                                    <DataTemplate>
                                        <r:ItemContainer>
                                            <r:Label Location="0%,0" Size="30%,20"  Background="{Binding QTitle}" BorderBrush="#ACE6EF"  BorderThickness="1,0,1,1" Padding="5,0,0,0" Text="[SID]" />
                                            <r:Label Location="30%,0" Size="30%,20"  Background="{Binding QTitle}" BorderBrush="#ACE6EF" BorderThickness="0,0,1,1" Padding="5,0,0,0" Text="[SName]"/>
                                            <r:Label Location="60%,0" Size="40%,20"  Background="{Binding QTitle}" BorderBrush="#ACE6EF" BorderThickness="0,0,1,1" Padding="5,0,0,0" Text="[SReply]"/>
                                        </r:ItemContainer>
                                    </DataTemplate>
                                </r:DataRange.ItemTemplate>
                            </r:DataRange>
                           
                            <r:DataRange  Name="EliminationList" Location="0%,100" Size="100%,20" >
                                <r:DataRange.HeaderTemplate>
                                    <DataTemplate>
                                        <r:ItemContainer Size="100%,20">
                                            <!--EliminationList-->
                                            <r:Label  Location="0%,0" Size="100%,20" Background="#B8DAE3" BorderBrush="#ACE6EF" BorderThickness="1,0,0,0" Padding="5,0,0,0" Text="Elimination List" FontSize="14" />
                                        </r:ItemContainer>
                                    </DataTemplate>
                                </r:DataRange.HeaderTemplate>
                                <r:DataRange.ItemTemplate>
                                    <DataTemplate>
                                        <r:ItemContainer>
                                            <r:Label Location="0%,0" Size="100%,20" BorderBrush="#ACE6EF"  BorderThickness="1,1,1,0" Padding="5,0,0,0" Text="[SName]"/>
                                        </r:ItemContainer>
                                    </DataTemplate>
                                </r:DataRange.ItemTemplate>
                            </r:DataRange>
                        </r:ItemContainer>
                    </DataTemplate>
                </r:DataRange.ItemTemplate>
            </r:DataRange>


I wanna to control "EliminationList" DataRange to show or hide.

thx..

Title: Re: The empty DataRange can NOT be exported to PDF
Post by Meppy on May 15th, 2013 at 9:44am
You can handle the QueryDetails event of the report, inspect the sender's name and if it is "EliminationList", do one of the following depending on whether you want to show or hide the range:

  • To hide the range, simply assign an empty IEnumerable (for example new object[] {}) to QueryDetailsEventArgs.Details. This will indicate that the range is empty.
  • To show the range, set Details to null and DataRange.Repeat to 1.

Let me know if this helps.

Regards,
Meppy

Title: Re: The empty DataRange can NOT be exported to PDF
Post by luolishuang on May 16th, 2013 at 12:58am

Meppy wrote on May 15th, 2013 at 9:44am:
You can handle the QueryDetails event of the report, inspect the sender's name and if it is "EliminationList", do one of the following depending on whether you want to show or hide the range:

  • To hide the range, simply assign an empty IEnumerable (for example new object[] {}) to QueryDetailsEventArgs.Details. This will indicate that the range is empty.
  • To show the range, set Details to null and DataRange.Repeat to 1.

Let me know if this helps.

Regards,
Meppy


Yeah, it will hide the DataRange, but this will throw exception when exporting to PDF

Title: Re: The empty DataRange can NOT be exported to PDF
Post by Meppy on May 16th, 2013 at 7:38am
Hi,

I have sent you an e-mail with an updated version that should address this problem.

Regards,
Meppy

Title: Re: The empty DataRange can NOT be exported to PDF
Post by luolishuang on May 17th, 2013 at 1:11am

Meppy wrote on May 16th, 2013 at 7:38am:
Hi,

I have sent you an e-mail with an updated version that should address this problem.

Regards,
Meppy


Hi,

Thanks for your great help, the problem is solved,
but there is still little problem, when the "EliminationList" DataRange is hidden, the area is still exist, like image below

The blank area can be removed?
2013-5-17_9-03-24.png (Attachment deleted)

Title: Re: The empty DataRange can NOT be exported to PDF
Post by Meppy on May 17th, 2013 at 9:40am
Hi,

You can try setting the height of the DataRange in question to 0 (that is, set Size to "W,0" where W is your current value for width). If the range has any content, it will be resized accordingly so that the content fits; if it is empty, it should take no space. However, the header of the data range (if any) will still be accounted for.

Regards,
Meppy

Title: Re: The empty DataRange can NOT be exported to PDF
Post by luolishuang on May 20th, 2013 at 1:56am
Hi,

I set my "AnswerList" and "EliminationList" DataRange size's height to 0, but seem still the same effect.

Title: Re: The empty DataRange can NOT be exported to PDF
Post by Meppy on May 20th, 2013 at 5:41am
Hi,

Can you please attach the full XAML of your report?

Regards,
Meppy

Title: Re: The empty DataRange can NOT be exported to PDF
Post by luolishuang on May 20th, 2013 at 6:59am

Meppy wrote on May 20th, 2013 at 5:41am:
Hi,

Can you please attach the full XAML of your report?

Regards,
Meppy


This is my full XAML report below,
thanks.


Code (html):
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:r="http://mindfusion.eu/reporting/wpf">
   
    <r:Report x:Key="EliminationReport" FontFamily="Arial" FontSize="12">
        <r:Page >
            <!-- Page Content-->
            <r:DataRange DataSource="{Binding QuestionTable}" Size="100%,100">
                <r:DataRange.ItemTemplate >
                    <DataTemplate >
                        <r:ItemContainer >
                           
                            <!--Note Info-->
                            <r:Label Location="0,0" Size="100%,20" Background="#EAA41E" BorderBrush="#ACE6EF" BorderThickness="1,1,1,0" Text="(Note:__ means No Answer,_N means you got the chance to answer but did not answer in Rush Quiz Mode)" FontSize="14" />
                            <r:Label Location="0%,20" Size="100%,20" Background="#B8DAE3" Text="[QTitle]" BorderBrush="#ACE6EF" BorderThickness="1,1,1,0" FontSize="14"/>
                            <r:Label Location="0%,40" Size="30%,20" Background="#F8F488" BorderBrush="#ACE6EF"  BorderThickness="1,0,1,1" Padding="5,0,0,0" Text="Participant ID" FontSize="14" />
                            <r:Label Location="30%,40" Size="30%,20" Background="#F8F488" BorderBrush="#ACE6EF"  BorderThickness="0,0,1,1" Padding="5,0,0,0" Text="Full Name" FontSize="14" />
                            <r:Label Location="60%,40" Size="40%,20" Background="#F8F488" BorderBrush="#ACE6EF"  BorderThickness="0,0,1,1" Padding="5,0,0,0" Text="Response" FontSize="14" />

                            <r:DataRange  Name="AnswerList" Location="0%,60" Size="100%,0">
                                <r:DataRange.ItemTemplate>
                                    <DataTemplate>
                                        <r:ItemContainer>
                                            <r:Label Location="0%,0" Size="30%,20"  Background="{Binding QTitle}" BorderBrush="#ACE6EF"  BorderThickness="1,0,1,1" Padding="5,0,0,0" Text="[SID]" />
                                            <r:Label Location="30%,0" Size="30%,20"  Background="{Binding QTitle}" BorderBrush="#ACE6EF" BorderThickness="0,0,1,1" Padding="5,0,0,0" Text="[SName]"/>
                                            <r:Label Location="60%,0" Size="40%,20"  Background="{Binding QTitle}" BorderBrush="#ACE6EF" BorderThickness="0,0,1,1" Padding="5,0,0,0" Text="[SReply]"/>
                                        </r:ItemContainer>
                                    </DataTemplate>
                                </r:DataRange.ItemTemplate>
                            </r:DataRange>
                           
                            <r:DataRange  Name="EliminationList" Size="100%,0" >
                                <r:DataRange.HeaderTemplate>
                                    <DataTemplate>
                                        <r:ItemContainer Size="100%,20">
                                            <!--EliminationList-->
                                            <r:Label  Location="0%,0" Size="100%,20" Background="#B8DAE3" BorderBrush="#ACE6EF" BorderThickness="1,0,0,0" Padding="5,0,0,0" Text="Elimination List" FontSize="14" />
                                        </r:ItemContainer>
                                    </DataTemplate>
                                </r:DataRange.HeaderTemplate>
                                <r:DataRange.ItemTemplate>
                                    <DataTemplate>
                                        <r:ItemContainer>
                                            <r:Label Location="0%,0" Size="100%,20" BorderBrush="#ACE6EF"  BorderThickness="1,1,1,0" Padding="5,0,0,0" Text="[SName]"/>
                                        </r:ItemContainer>
                                    </DataTemplate>
                                </r:DataRange.ItemTemplate>
                            </r:DataRange>
                        </r:ItemContainer>
                    </DataTemplate>
                </r:DataRange.ItemTemplate>
            </r:DataRange>
            
            <!-- Page Footer -->
            <r:Page.FooterTemplate>
                <DataTemplate>
                    <r:ItemContainer Size="100%,30">
                        <r:Label Size="100%,30" Text="[PageCurrent()]/[PageCount()]" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    </r:ItemContainer>
                </DataTemplate>
            </r:Page.FooterTemplate>            
        </r:Page>
    </r:Report>   
</ResourceDictionary>

Title: Re: The empty DataRange can NOT be exported to PDF
Post by Meppy on May 20th, 2013 at 9:33am
Hi,

I have e-mailed you a new version of the control. Now, in addition to setting the heights of AnswerList and EliminationList to 0, now also set the height of the primary data range to 0. This is to indicate that the data range needs to be auto-sized based on its content.

Regards,
Meppy

Title: Re: The empty DataRange can NOT be exported to PDF
Post by luolishuang on May 21st, 2013 at 2:05am
Hi Meppy, thanks for your great help.

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.