AR Section Report calls detail_format when there are no rows

Posted by: tniec on 5 October 2017, 6:40 am EST

  • Posted 5 October 2017, 6:40 am EST

    This is for Active Reports 10.

    I am setting a section report’s DataSource to a DataSet where the “main” table (Table identified by the SectionReport.DataMember property) has no rows. (This is occurring because our code is filtering out all rows from a data source and this leaves a table with no rows left, this is a reasonable occurrence for our purposes.)

    However, when we print the report (render it to the viewer control). We are finding that the dewtail_format section event is being called and that the script code in that event is throwing an exception because some of the data it is manipulating is invalid–because there really is no data.

    Why is detail_format being called if there is no rows? Can we turn that off. I want this to “print” and “empty” report–that UI makes sense. I don’t want to abort the print.

    Note, when we have no script code, we don’t get the exception and we do print an “empty” report.

  • Posted 5 October 2017, 11:42 pm EST

    Since you have a script in the detail format event which manipulates the data, you could handle the NoData event and assign a global variable, which you can check in the detail format event as below:

    bool noRows = false;
    
    private void detail_Format(object sender, EventArgs e)
            {
                if (!noRows)
                {
                    //write your code
                }       
            }
    
    private void SectionReport2_NoData(object sender, EventArgs e)
            {
                noRows = true;
            }
    

    Hope it helps

  • Posted 9 October 2017, 6:20 am EST

    That prevents the exception, as does a check for NULL or placing things in a Try…Catch block.

    but the heart of the problem still remains. The detail_format should be called once for every data row to be printed. If there are 3 rows, then it would be called 3 times etc.

    However, when there are no rows, it is still called once even though there is no data to format. Isn’t that a bug?

  • Posted 10 October 2017, 2:02 am EST

    Allow me to get in touch with the development team regarding this and get back to you. Tracking Id - 247111

  • Posted 10 October 2017, 11:17 pm EST

    I have received information from the development team on this and it is a design behavior. If the format and other events are not fired even once, then it’ll be equivalent to calling report.cancel() and no controls would be displayed.

    Hope it clarifies

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels