Add sum row programmatically

1 Answer 125 Views
.NET Core Grouping Table
devnb
Top achievements
Rank 1
devnb asked on 16 Feb 2023, 04:06 PM

Greetings!

I have some reports that contain tables created dynamically by the C# application. The procedure is more or less similar to what you describe in the documentation. Those reports are inserted in a report book and displayed in an Angular app with the viewer.  My problem is this: some of those reports need an extra row added that will sum the content of columns with monetary values. This row must be either at the bottom of the report or at the bottom of a group inside the table. I 've read relevant entries in the forum and the documentation, but all I could find is how to add the sum row in the designer, which is not my case. So what I'm asking is if there is any way to add it programmatically. 

Thanks!

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 21 Feb 2023, 09:44 AM

Hello Konstantinos,

If I understand correctly, the whole tables are designed in code and then added to the report, is that correct? If that is indeed the case, may I ask what is the reason for doing this in code rather than using the dedicated Report Designers?

It is not recommended to design reports or report items via code. Instead of that, we recommend Using ExpressionsConditional FormattingBindings, and User Functions to add dynamicity to your report, if that is what you are looking for when using code instead.

These tools are typically the most productive way to build declarative reports and I suggest trying to make the tables in the report designers and then dynamically hiding the totals when they are not needed with the linked approaches.

Still, if you are interested in how a total may be added in code, you may try to create a new .NET type report and then you may use the Visual Studio Report Designer to insert a table in that report and a total row. The VS Report Designer will automatically add the code for how that is done in the Report.Designer.cs file of your report and that will allow you to see how you may add it to the real report.

Please do not hesitate to let me know if you have any further questions.

Regards,
Dimitar
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
devnb
Top achievements
Rank 1
commented on 21 Feb 2023, 11:24 AM

Hello Dimitar,

You do understand correctly. The first reason is that we have 50 something reports that all have different columns and data types, so we have 50 something different tables, which were easier for us to create through code and not with the designer, given our deadlines etc. The second reason is that I am working on this existing code that was handed over to me and it's not currently possible to rework the whole functionality. I'll check the Visual Studio Report Designer as soon as I have some time and I'll get back to you. Thanks a lot!

Dimitar
Telerik team
commented on 23 Feb 2023, 02:37 PM

Hello Konstantinos,

Thank you for sharing details about the scenario!

Considering what you have said, I won't push you to make big changes but in the future, I definitely recommend test-running our Report Designers. Once a report is designed, it can be reused with multiple data sets and the code in the end could up being just a couple of checks for which report should be used for the current data.

I hope that the Visual Studio Report Designer will help you figure out how to do this in your code, feel free to let me know if you need additional assistance or if you have other questions.

Tags
.NET Core Grouping Table
Asked by
devnb
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or