CellTemplateSelector Format Cells

2 posts, 0 answers
  1. Heath
    Heath avatar
    6 posts
    Member since:
    Feb 2014

    Posted 29 Apr 2015 Link to this post

    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;
    03. if (cellAggregate != null)
    04. {
    05.     var description = cellAggregate.Description as PropertyAggregateDescription;
    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;
    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. }
    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?




  2. Polya
    Polya avatar
    191 posts

    Posted 01 May 2015 Link to this post

    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:

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


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

  3. DevCraft banner
Back to Top