How to identify last item in data source for detail section

3 posts, 0 answers
  1. James
    James avatar
    6 posts
    Member since:
    Aug 2012

    Posted 24 Feb 2015 Link to this post

    I have a report that is bound to a list of business objects, where the Detail section is repeated once for each business object in the list.  The Detail section has a divider line at the bottom that helps to visually distinguish each section.  I don't want that divider line to show up after the very last section though.

    I've had trouble finding out how to implement this.  It looks like in the past I could have used a Conditional Formatting on the divider line (it's actually a Shape inside of a Panel, and I want to just hide the Panel).  I could have had an expression that said if =RowNumber() = =Count(RowNumber()) then set the panel invisible, but this doesn't work anymore because it was broken when some Scope features were added.

    I've tried the ItemDataBinding event on the Detail section, but I can't see how I can get the current row number or the total number of rows in the data source.  All I need to know is if the current row is the last row, and then I could use this event to hide the divider line.

    What's the correct way to go about this?

  2. James
    James avatar
    6 posts
    Member since:
    Aug 2012

    Posted 24 Feb 2015 in reply to James Link to this post

    I implemented it this way, which works, but seems rather hacky.

            private void detail_ItemDataBinding(object sender, EventArgs e)
            {
                detailSectionCount++; //This is a private variable to keep track of which item is being processed; seems hacky to me

                var section = (sender as Telerik.Reporting.Processing.DetailSection);
                var divPanel = (Telerik.Reporting.Processing.Panel)Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(section, "pnlDivider");

                var dataSource = (List<Strand>)section.Report.DataSource;

                if (detailSectionCount == dataSource.Count)
                {
                    divPanel.Visible = false;
                }
            }
  3. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 27 Feb 2015 Link to this post

    Hi James,

    Test using the Exec data function where you can specify the data scope of the function, and aggregate functions to check if the current section displays the last record in the assigned to the report data. If the condition is met, do not draw the border or hide the shape item.

    For example, we can base a conditional formatting rule on the following filter:
    Expression: =Exec('Report1',Count(1))=RowNumber('Report1')
    Operator: =(equals)
    Value: =True
    Which will be triggered only for the last detail.


    If you need further help, feel free to open a support ticket and send us the report's code files to check your settings.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top