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

How aggregate data from child detail items when using OpenAccessDataSource ORM

3 Answers 94 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Patrick Saunders
Top achievements
Rank 1
Patrick Saunders asked on 30 Jul 2012, 07:12 AM
I have my report working (mostly) nicely with Telerik ORM (ignoring that the report Preview has a heart attack 50% of the time).

I have two Open Access Data Sources.
oadsOrders = Main data, 1 record per page.
oadsOrderItems = Order detail, many per Order, displayed in a report table.

See screenshots:
report.png = report designer.
mass 2.jpg = screenshot showing how I oadsOrderItems is populated using parameter from oadsOrders


Problem:
I need to show report order total, ie sum(orderItem.amount) though I can't figure a good way to do this.
Telerik report doesn't navigate into 1-N relationships it seems, so I can't tell it to aggregate like this sum(Order.OrderItems.amount) .

I can use custom functions, but they are static and don't know about reportItem, nor could I seem to pass that in properly - it didn't recognise the function.

Do I have to create ANOTHER datasource so that values from OrderItems can be aggreated? Seems like overkill to me..

Thanks,

Pat.

3 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 01 Aug 2012, 08:57 AM
Hi Patrick,

If I understood correctly, you need to aggregate the data that is inside the table. This cannot be done using expressions only. You have several options:
  1. As you guessed you can create another 'fake' table with the same data-source just to get the sum.
  2. Create a static row group in the same table and put the aggregate expressions there. If this is acceptable for your layout, it's the best approach.
  3. You can do the following trick - hook up to ItemDataBound event of the TextBoxes you want to sum up. Take their value and save it in a private variable. Also hook up to the ItemDataBound event of the TextBox you want to show the aggregated value and assign the variable as its value. Then set the variable = 0 for the next rendering. You can see that approach in the attached sample report.
 
Kind regards,
Elian
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Patrick Saunders
Top achievements
Rank 1
answered on 01 Aug 2012, 10:18 AM
Hi Elian,
Thanks for the reply.

I did create another report table on the report, and setting its datasource to the oadsOrderItems, and then putting sums into that. I rotated the table so the fields went down the page, instead of across. This is what you mean by #1 correct?

So there's no problem with having two report objects using the same datasource?
See screenshot attached.

In some ways, this is a big disadvantage of using entity objects - there is no flexibility to derive or aggregate other fields, correct?

Regards,

Pat.
0
Elian
Telerik team
answered on 03 Aug 2012, 01:26 PM
Hello Patrick,

Yes, this is what I meant.
Your guess is correct - you can't derive from previously defined expressions, reusing calculations is only possible with user functions and custom code (as in suggestion #3).
 
Greetings,
Elian
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
Patrick Saunders
Top achievements
Rank 1
Answers by
Elian
Telerik team
Patrick Saunders
Top achievements
Rank 1
Share this question
or