Hi All,
Following this demo, http://www.telerik.com/help/aspnet-ajax/pivotgrid-custom-data-calculations.html, I'm go one step further to create the calculated items programmatically in c# (instead of aspx).
Here's the part of code under onLoad event that I've tried:
PivotGridCalculatedItem newCalulation = new PivotGridCalculatedItem();
newCalulation.GroupName = "Testing: XXYY";
foreach (PivotGridField GridField in RadPivotGrid1.Fields)
{
if (GridField.FieldType.ToString() == "PivotGridColumnField" && GridField.UniqueName == "CreationYear")
{
(GridFieldas PivotGridColumnField).CalculatedItems.Add(newCal);
}
}
But it's not working an giving me an 'Object reference not set to an instance of an object.' error. Please advise.
Best regards.
Following this demo, http://www.telerik.com/help/aspnet-ajax/pivotgrid-custom-data-calculations.html, I'm go one step further to create the calculated items programmatically in c# (instead of aspx).
Here's the part of code under onLoad event that I've tried:
PivotGridCalculatedItem newCalulation = new PivotGridCalculatedItem();
newCalulation.GroupName = "Testing: XXYY";
foreach (PivotGridField GridField in RadPivotGrid1.Fields)
{
if (GridField.FieldType.ToString() == "PivotGridColumnField" && GridField.UniqueName == "CreationYear")
{
(GridFieldas PivotGridColumnField).CalculatedItems.Add(newCal);
}
}
But it's not working an giving me an 'Object reference not set to an instance of an object.' error. Please advise.
Best regards.