Hi,
I have managed to successfully create Pivot Grids from code behind, the definition of the pivot grid, rows, columns and aggregates and filters are stored in SQL Server, I am able to easily create the grid at run time and display it. The sorting, column filters, row filters all work well. However the PivotGridReportFilterField defined when clicked fail with
[NullReferenceException: Object reference not set to an instance of an object.] Telerik.Web.UI.PivotGridFilterWindow.InitializeControls() +904 Telerik.Web.UI.PivotGridFilteringManager.CreateFilterWindow() +90 Telerik.Web.UI.PivotGridFilteringManager.SetUpFilterWindowControls() +14 Telerik.Web.UI.RadPivotGrid.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +723
In the code behind, I construct the grid as follows:
foreach
(var def
in
defList)
{
if
(def.ReportFieldType == (
int
) ReportFieldType.RowFieldForTable)
{
// Define Rows var rowField = new PivotGridRowField();
PivotGrid.Fields.Add(rowField);
rowField.DataField = def.Fieldname;
rowField.UniqueName = def.Fieldname.Replace(
" "
,
string
.Empty);
}
else
if
(def.ReportFieldType == (
int
) ReportFieldType.ColumnFieldForTable)
{
// Define Columns var colField = new PivotGridColumnField();
PivotGrid.Fields.Add(colField);
colField.DataField = def.Fieldname;
colField.UniqueName = def.Fieldname.Replace(
" "
,
string
.Empty);
}
else
if
((def.ReportFieldType == (
int
) ReportFieldType.CountFieldForTable) || (def.ReportFieldType == (
int
) ReportFieldType.AverageFieldForTable) || (def.ReportFieldType == (
int
) ReportFieldType.SumFieldForTable))
{
//Define Aggregrates var aggregateField = new PivotGridAggregateField();
PivotGrid.Fields.Add(aggregateField);
aggregateField.DataField = def.Fieldname;
aggregateField.UniqueName = def.Fieldname.Replace(
" "
,
string
.Empty);
if
(def.ReportFieldType == (
int
) ReportFieldType.CountFieldForTable) aggregateField.Aggregate = PivotGridAggregate.Count;
if
(def.ReportFieldType == (
int
) ReportFieldType.AverageFieldForTable) aggregateField.Aggregate = PivotGridAggregate.Average;
if
(def.ReportFieldType == (
int
) ReportFieldType.SumFieldForTable) aggregateField.Aggregate = PivotGridAggregate.Sum;
}
else
if
(def.ReportFieldType == (
int
) ReportFieldType.FilterFields)
{
var filterField =
new
PivotGridReportFilterField();
PivotGrid.Fields.Add(filterField);
filterField.DataField = def.Fieldname;
filterField.UniqueName = def.Fieldname.Replace(
" "
,
string
.Empty);
//filterField.FilterType = PivotGridReportFilterActionType.Includes; }
}
Any help in resolving this issue would be much appreciated.
Thanks