Master Component not displaying when child component empty

Stimulsoft Reports.NET discussion
Post Reply
aaronrc
Posts: 23
Joined: Thu Apr 05, 2012 2:41 am

Master Component not displaying when child component empty

Post by aaronrc »

I have a report that uses a master data band and several child data bands that all reference the master data band. The report displays correctly except when there is no data to display in the child data bands in which case the master band will also not be displayed. I need the master band to be displayed irrespective of whether there is any matching child data or not.

The code snippet below will correctly display the report (a cut down report template that illustrates my issue is attached). If I break the link between the master data source (which is IncidentLog) and the child data source (which is IncidentLogComment) by commenting the line, IncidentID = Guid.Empty.ToString(), then no data will be displayed. How can I get the master IncidentLog data source to display even when there is no matching IncidentLogComment?

Code: Select all

public class IncidentLogReportEntity
    {
        public string ID { get; set; }
        public int IncidentNumber { get; set; }
        public string LocationName { get; set; }
        public DateTime IncidentDateTime { get; set; }
        public string WerePoliceCalled { get; set; }
        public string IsReportable { get; set; }
        public string ManagerPreferredName { get; set; }
        public string InsertedByPreferredName { get; set; }
        public string IncidentTypesCSV { get; set; }
        public string IncidentDetail { get; set; }
        public string IncidentAction { get; set; }
    }

    public class IncidentLogCommentEntity
    {
        public string IncidentID { get; set; }
        public int IncidentCommentNumber { get; set; }
        public string Comment { get; set; }
        public DateTime Inserted { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Report Designer");

            IncidentLogReportEntity incident = new IncidentLogReportEntity()
            {
                ID = Guid.Empty.ToString(),
                IncidentNumber = 1,
                IncidentDateTime = DateTime.Now,
                IncidentDetail = "Blah blah blah..."
            };

            IncidentLogCommentEntity comment = new IncidentLogCommentEntity()
            {
                IncidentID = Guid.Empty.ToString(),
                Comment = "Blah blah..."
            };  

            StiReport report = new StiReport();
            report.Load("IncidentLogReport.mrt");

            report.RegData("IncidentLog", new List<IncidentLogReportEntity> { incident });
            report.RegData("IncidentLogComment", new List<IncidentLogCommentEntity> { comment });

            report.Compile();

            report.Design();
            //report.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, "incident_log_report.pdf");

            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
   }
Attachments
IncidentLogReport.mrt
(24.22 KiB) Downloaded 424 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Master Component not displaying when child component emp

Post by Alex K. »

Hello,

Please try to set the PrintIfDetailEmpty property to true for the master databand component.

Thank you.
aaronrc
Posts: 23
Joined: Thu Apr 05, 2012 2:41 am

Re: Master Component not displaying when child component emp

Post by aaronrc »

That was the fix, thanks.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Master Component not displaying when child component emp

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply