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

Adding Percents to Grouped Items in Crosstab

4 Answers 369 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
brian piccolo
Top achievements
Rank 1
brian piccolo asked on 07 Jul 2009, 12:27 PM
Hello,

I have created a new report using the CrossTab Wizard in the Q2 release.  It's great!  However, I'd like to now add a column to the report to display a percentage based on subtotals in the crosstab.

I've tried using the ItemDataBound event of the Detail section, Crosstab and TextBox processing elements using the examples that I've found on this website and forum:

Forum Post Percent Example
http://www.telerik.com/community/forums/reporting/telerik-reporting/use-report-footer-fields-in-group-field-calculation.aspx

Custom Aggregate Function
http://www.telerik.com/support/kb/reporting/general/implementing-and-using-custom-aggregate-functions.aspx

Combining Values from Documentation
http://www.telerik.com/help/reporting/faq-combine-values2.html

When I try to use the example fromt he documentation, the DataObject.Rawdata property is null so I can't access the DataRowView object in the detail_ItemDataBound event.  I suspect it's because of the way the crosstab control is rendered but I spent several hours yesterday playing around with different combinations in the different event handlers but haven't had much luck.

Can anyone point me in the right direction?  I can provide code examples if necessary.

Thanks in advance!
Brian

4 Answers, 1 is accepted

Sort by
0
brian piccolo
Top achievements
Rank 1
answered on 08 Jul 2009, 02:29 AM
Hello, does anyone have any suggestions?  I've tried a few additional approaches including trying to use the Report property of the detail section, text box, or crosstab objects but haven't had any luck.  Any information would be greatly appreciated.
0
Steve
Telerik team
answered on 10 Jul 2009, 12:18 PM
Hi Brian,

DataObject.RawData is available for the child items of the respective parent only i.e. report, section, panel, table item. So if you have bound a table item to a datasource, it would be available for the items within that table and there is no way to get to it in the detail or table ItemDataBound event. However if you set DataSource for the report, DataObject.RawData would be available for items in the report sections.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
brian piccolo
Top achievements
Rank 1
answered on 10 Jul 2009, 12:38 PM
Hi Steve,

Thanks for the reply.  I've tried adding the datasource to the report itself but when I do, the crosstab report doesn't return any data at all.  The only way I can get data is to add the datasource to the crosstab.  The example provided in my ticket was created usign the crosstab wizard.

I'm really looking to reproduce the functionality from the Percent example link  - http://www.telerik.com/community/forums/reporting/telerik-reporting/use-report-footer-fields-in-group-field-calculation.aspx - but within the crosstab.  Is this possible?  Seems like I need to get at the report data rather than the raw data from the datasource in order to calculate the percentages.

Any additional thoughts?

Thanks
Brian
0
Steve
Telerik team
answered on 10 Jul 2009, 03:16 PM
Hello Brian,

I think I've been misunderstood. The table item can be looked upon as separate "data region" and thus you need to databind it if you would expect it show your data fields. What I was trying to imply is that the DataObject.RawData would be available for the child items only and that is why it is not available in the ItemDataBound event of the table itself.
Seems like I need to get at the report data rather than the raw data from the datasource in order to calculate the percentages.
For the scenario you're aiming at, it would be best to add a new column to your datasource, where to calculate the percentage and only display it in the table. It can be achieved with reporting expressions as well, but this would require good understanding of the table/crosstab API, as you would need to cycle through its cells and locate the desired item.
While doing this at database level would only require you to add =First(Fields.MyPercentDataField) to the textbox expression.

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
brian piccolo
Top achievements
Rank 1
Answers by
brian piccolo
Top achievements
Rank 1
Steve
Telerik team
Share this question
or