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

How to identify last item in data source for detail section

2 Answers 696 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 24 Feb 2015, 05:26 PM
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 Answers, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 24 Feb 2015, 05:38 PM
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;
            }
        }
0
Stef
Telerik team
answered on 27 Feb 2015, 10:37 AM
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.

 
Tags
General Discussions
Asked by
James
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Stef
Telerik team
Share this question
or