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

CellTemplateSelector Format Cells

1 Answer 33 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Heath
Top achievements
Rank 1
Heath asked on 29 Apr 2015, 08:19 PM

Hi Telerik Team,

I'm trying to format the cells of my pivot table and I've seen this link but what I want to do is get the dataitem bound to the cell and test the condition of other members in the dataitem to determine which template to return.

 

So instead of this 

 

01.var cellAggregate = item as CellAggregateValue;
02. 
03. if (cellAggregate != null)
04. {
05.     var description = cellAggregate.Description as PropertyAggregateDescription;
06. 
07.     if (cellAggregate.RowGroup.Type == GroupType.BottomLevel && cellAggregate.ColumnGroup.Type == GroupType.BottomLevel)
08.     {
09.         if (Convert.ToDouble(cellAggregate.Value) > 1000d)
10.         {
11.             return this.GreenTemplate;
12.         }
13.         else
14.         {
15.             return this.RedTemplate;
16.         }
17.     }
18. }

 

I'd like to try and achieve this

 

01.var items = item as WS_BSQ.View_TestHistory;
02. 
03. if (items != null)
04. {
05.     if (items.Passed == null)
06.     {
07.         return base.SelectTemplate(item, container);
08.     }
09.     if (Convert.ToBoolean(items.Passed) == true)
10.     {
11.         return this.GreenTemplate;
12.     }
13.     else
14.     {
15.         return this.RedTemplate;
16.     }
17. }
18. 
19. return base.SelectTemplate(item, container);

 

but I can't seem to find how to expose the item it's bound to in the CellAggregateVaue, or is there another way to go about this?

 

Cheers,

 

1 Answer, 1 is accepted

Sort by
0
Polya
Telerik team
answered on 01 May 2015, 12:37 PM
Hi Heath,

RadPivotGrid is a control using data summarization of grouped, aggregated and filtered data.
Because of that each cell aggregate value displays a result of a calculation operation and does not match to one specific data record from the ItemsSource.
Instead, for example, it displays a sum of all records from the ItemsSource that match the specified grouping and filtering. If you take a look the attached CellAggregateValue.png scenario - the cell aggregate value "168" is calculated from those records from the ItemsSource that have a Product - "Copy Holder", a Promotion - "Extra Discount" and an Advertisement - "Direct Mail". We sum the Quantity of these records and place it as value for the red bordered cell.

If you wish to extract the records that we use to calculate a specific cell aggregate value, I am afraid that this is not available with the current implementation of RadPivotGrid. We have logged a similar feature request in our Feedback Portal where you can track its status. It is available at this link:
http://feedback.telerik.com/Project/143/Feedback/Details/113499-implement-drilldown-functionality-for-radpivotgrid-for-localdatasourceprovider

Could you please specify what item do you wish to extract if my suggestion is not what you've meant?

Regards,
Polya
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
PivotGrid
Asked by
Heath
Top achievements
Rank 1
Answers by
Polya
Telerik team
Share this question
or