How to reproduce: var data = this.dbContext.Orders.Where(o => o.OrderID > 10500).Select(o => new { Id = o.OrderID, OrderDate = o.OrderDate, ShipDate = o.ShippedDate, Freight = o.Freight }).ToArray(); this.localDataProvider = new LocalDataSourceProvider() {ItemsSource = data}; Workaround: 1. Instead of ToArray call ToList var data = this.dbContext.Orders.Where(o => o.OrderID > 10500).Select(o => new { Id = o.OrderID, OrderDate = o.OrderDate, ShipDate = o.ShippedDate, Freight = o.Freight }).ToList(); this.localDataProvider = new LocalDataSourceProvider() {ItemsSource = data}; 2. Call the ToArray method but do not create anonymous objects. var data = this.dbContext.Orders.Where(o => o.OrderID > 10500).Select(o => new PivotModel { Id = o.OrderID, OrderDate = o.OrderDate, ShipDate = o.ShippedDate, Freight = o.Freight }).ToArray(); this.localDataProvider = new LocalDataSourceProvider() {ItemsSource = data}; public class PivotModel { public int Id { get; set; } public DateTime? OrderDate { get; set; } public DateTime? ShipDate { get; set; } public decimal? Freight { get; set; } }
Workaround: private void PrintPivotGrid() { MyPivotGridPrintStyle style = new MyPivotGridPrintStyle(); style.LayoutType = PivotLayout.Tabular; this.radPivotGrid1.PrintStyle = style; this.radPivotGrid1.PrintPreview(); } public class MyPivotGridPrintStyle : PivotGridPrintStyle { public override void Initialize() { base.Initialize(); FieldInfo fiColumnWidths = this.GetType().BaseType.GetField("columnWidths", BindingFlags.Instance | BindingFlags.NonPublic); List<int> columnWidths = (List<int>)fiColumnWidths.GetValue(this); RadPivotGridElement pivotGrid = (RadPivotGridElement)this.GetType().BaseType.GetField("pivotGrid", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this); for (int i = 0; i < pivotGrid.RowDescriptorsArea.Children.Count; i++) { RadElement descriptor = pivotGrid.RowDescriptorsArea.Children[i]; columnWidths[i] = descriptor.Size.Width; } } }
Until the feature becomes available use the following workaround: MyPivotGridChartDataProvider chartProvider = new MyPivotGridChartDataProvider(this.radPivotGrid1.PivotGridElement); this.radPivotGrid1.ChartDataProvider = chartProvider; this.radChartView1.DataSource = this.radPivotGrid1; this.radChartView1.ShowLegend = true; this.radPivotGrid1.ChartDataProvider.SeriesAxis = Telerik.Pivot.Core.PivotAxis.Rows; this.radPivotGrid1.ChartDataProvider.GeneratedSeriesType = Telerik.WinControls.UI.GeneratedSeriesType.Line; public class MyPivotGridChartDataProvider : PivotGridChartDataProvider { public MyPivotGridChartDataProvider(RadPivotGridElement pivotGridElement) : base(pivotGridElement) { } public override void UpdateChartData() { base.UpdateChartData(); foreach (ChartSeries series in this.ChartView.Series) { CartesianSeries cartesianSeries = series as CartesianSeries; if (cartesianSeries == null) { continue; } cartesianSeries.PointSize = new SizeF(7, 7); BindingList<PivotChartModelPoint> newData = new BindingList<PivotChartModelPoint>(); BindingList<PivotDataPoint> points = cartesianSeries.DataSource as BindingList<PivotDataPoint>; foreach (PivotDataPoint point in points) { PivotChartModelPoint current = new PivotChartModelPoint() { Group = point.PivotGroup }; if (point.Value != 0) { current.Value = point.Value; } else { current.Value = null; } newData.Add(current); } cartesianSeries.DataSource = null; cartesianSeries.CategoryMember = "Group"; cartesianSeries.ValueMember = "Value"; cartesianSeries.DataSource = newData; } } } public class PivotChartModelPoint { public string Group{ get; set; } public double? Value { get; set; } }
Workaround: public Form1() { InitializeComponent(); this.radPivotFieldList1.ValuesControl.CreatingVisualListItem += Aggregates_CreatingVisualListItem; } private void Aggregates_CreatingVisualListItem(object sender, Telerik.WinControls.UI.CreatingVisualListItemEventArgs args) { args.VisualItem = new MyPivotFieldListVisualItem(this.radPivotFieldList1.ViewModel); } public class MyPivotFieldListVisualItem : PivotFieldListVisualItem { private FieldListViewModel viewModel; private CommandBarDropDownButton button; private RadMenuItem sumMenuItem; private RadMenuItem avgMenuItem; private RadMenuItem countMenuItem; public MyPivotFieldListVisualItem(FieldListViewModel viewModel) : base(viewModel) { this.viewModel = viewModel; } protected override void CreateChildElements() { base.CreateChildElements(); this.sumMenuItem = this.GetType().BaseType .GetField("sumMenuItem", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as RadMenuItem; this.avgMenuItem = this.GetType().BaseType .GetField("avgMenuItem", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as RadMenuItem; this.countMenuItem = this.GetType().BaseType .GetField("countMenuItem", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as RadMenuItem; if (sumMenuItem != null && avgMenuItem != null && countMenuItem != null) { sumMenuItem.Click += OnAggregateFunctionClick; avgMenuItem.Click += OnAggregateFunctionClick; countMenuItem.Click += OnAggregateFunctionClick; } this.button = this.GetType().BaseType .GetField("button", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as CommandBarDropDownButton; RadMenuItem aggregateOptionsMenuItem = this.GetType().BaseType .GetField("aggregateOptionsMenuItem", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as RadMenuItem; aggregateOptionsMenuItem.Click += aggregateOptionsMenuItem_Click; RadMenuItem numberFormatMenuItem = this.GetType().BaseType .GetField("numberFormatMenuItem", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as RadMenuItem; numberFormatMenuItem.Click += numberFormatMenuItem_Click; } private void numberFormatMenuItem_Click(object sender, EventArgs e) { Value value = (this.Data.DataBoundItem as Value); if (value == null) { return; } MyNumberFormatOptionsDialog dialog = new MyNumberFormatOptionsDialog(); dialog.ThemeName = this.GetThemeName(); QueryableAggregateDescription queryableAggregateDescription = (value.Description as QueryableAggregateDescription); if (queryableAggregateDescription != null) { dialog.LoadQueryableSettings(queryableAggregateDescription); } System.Windows.Forms.DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { queryableAggregateDescription.StringFormat = dialog.SelectedStringFormat; this.viewModel.ExecuteUpdate(); } } private void aggregateOptionsMenuItem_Click(object sender, EventArgs e) { MyAggregateOptionsDialog dialog = new MyAggregateOptionsDialog(); dialog.ThemeName = this.GetThemeName(); Value value = (this.Data.DataBoundItem as Value); if (value != null) { QueryablePropertyAggregateDescriptionBase queryableAggregateDescription = (value.Description as QueryablePropertyAggregateDescriptionBase); if (queryableAggregateDescription != null) { dialog.LoadQueryableSettings(queryableAggregateDescription); } System.Windows.Forms.DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { queryableAggregateDescription.AggregateFunction = dialog.SelectedQueryableAggregateFunction; queryableAggregateDescription.CustomName = dialog.CustomName; this.Synchronize(); this.viewModel.ExecuteUpdate(); } } } private void OnAggregateFunctionClick(object sender, EventArgs e) { Value value = (this.Data.DataBoundItem as Value); string function = ((RadMenuItem)sender).Text; if (value != null && this.SetNewAggregateFunction(value.Description, function)) { this.Synchronize(); this.viewModel.ExecuteUpdate(); } } private bool SetNewAggregateFunction(IAggregateDescription description, string function) { QueryablePropertyAggregateDescriptionBase queryableDescription = (description as QueryablePropertyAggregateDescriptionBase); if (queryableDescription != null) { switch (function) { case "Sum": queryableDescription.AggregateFunction = QueryableAggregateFunction.Sum; break; case "Count": queryableDescription.AggregateFunction = QueryableAggregateFunction.Count; break; case "Average": queryableDescription.AggregateFunction = QueryableAggregateFunction.Average; break; default: return false; } return true; } return false; } protected override void SynchronizeProperties() { base.SynchronizeProperties(); Value value = (this.Data.DataBoundItem as Value); Label label = (this.Data.DataBoundItem as Label); if (value != null) { #if !NETFX2 QueryablePropertyAggregateDescription queryableDescription = (value.Description as QueryablePropertyAggregateDescription); if (queryableDescription != null) { this.sumMenuItem.IsChecked = queryableDescription.AggregateFunction == QueryableAggregateFunction.Sum; this.countMenuItem.IsChecked = queryableDescription.AggregateFunction == QueryableAggregateFunction.Count; this.avgMenuItem.IsChecked = queryableDescription.AggregateFunction == QueryableAggregateFunction.Average; } #endif } } private string GetThemeName() { if (this.ElementTree == null) { return string.Empty; } RadControl control = this.ElementTree.Control as RadControl; return control != null ? control.ThemeName : string.Empty; } } public class MyAggregateOptionsDialog : AggregateOptionsDialog { private RadListControl listAggregateFunctions; private RadLabel labelFieldName; private RadTextBox textBoxCustomName; public MyAggregateOptionsDialog() { this.listAggregateFunctions = this.GetType().BaseType .GetField("listAggregateFunctions", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as RadListControl; this.labelFieldName = this.GetType().BaseType .GetField("labelFieldName", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as RadLabel; this.textBoxCustomName = this.GetType().BaseType .GetField("textBoxCustomName", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as RadTextBox; } private readonly IList<QueryableAggregateFunction> availableQueryableAggregateFunctions = new List<QueryableAggregateFunction>() { QueryableAggregateFunction.Sum, QueryableAggregateFunction.Count, QueryableAggregateFunction.Average, QueryableAggregateFunction.Max, QueryableAggregateFunction.Min }; public virtual QueryableAggregateFunction SelectedQueryableAggregateFunction { get { return (QueryableAggregateFunction)this.listAggregateFunctions.SelectedValue; } } public virtual void LoadQueryableSettings(QueryablePropertyAggregateDescriptionBase aggregateDescription) { if (this.listAggregateFunctions.DataSource != null) { this.listAggregateFunctions.DataSource = availableQueryableAggregateFunctions; } this.listAggregateFunctions.SelectedValue = aggregateDescription.AggregateFunction; this.labelFieldName.Text = aggregateDescription.PropertyName; this.Text = String.Format("{0}{1}{2}", "Aggregate Options (", aggregateDescription.PropertyName, ")"); this.textBoxCustomName.Text = aggregateDescription.CustomName; } } public class MyNumberFormatOptionsDialog : NumberFormatOptionsDialog { private TextBox textBox; public MyNumberFormatOptionsDialog() { RadDropDownList dropDownListFormat = this.GetType().BaseType .GetField("dropDownListFormat", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as RadDropDownList; this.textBox = (TextBox)dropDownListFormat.DropDownListElement.EditableElement.TextBox.TextBoxItem.HostedControl; } public virtual void LoadQueryableSettings(QueryableAggregateDescriptionBase aggregateDescription) { this.textBox.Text = aggregateDescription.StringFormat; this.Text = String.Format(PivotGridLocalizationProvider.CurrentProvider.GetLocalizedString(PivotStringId.NumberFormatOptionsDialogFormatOptionsDescription), aggregateDescription.DisplayName); this.textBox.Select(this.textBox.Text.Length, 0); this.textBox.Focus(); } }
Until the feature gets implemented use custom PivotGridPrintStyle: Public Class MyPivotGridPrintStyle Inherits PivotGridPrintStyle Const MIN_SPACE As Integer = 1 Public Overrides Sub DrawPage(drawArea As Rectangle, graphics As Graphics, pageNumber As Integer) If Me.PivotGrid.ColumnHeaderHeight > MIN_SPACE Then MyBase.DrawPage(drawArea, graphics, pageNumber) Else Dim x As Integer = drawArea.X Dim y As Integer = drawArea.Y Dim scale As SizeF = DirectCast(Me.GetType().BaseType.GetMethod("GetScaleFactors", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(Me, New Object() {drawArea}), SizeF) Dim startColumn As Integer = DirectCast(Me.GetType().BaseType.GetMethod("GetStartColumn", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(Me, New Object() {pageNumber, drawArea, scale.Width}), Integer) Dim endColumn As Integer = DirectCast(Me.GetType().BaseType.GetMethod("GetEndColumn", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(Me, New Object() {startColumn, drawArea, scale.Width}), Integer) Dim startRow As Integer = DirectCast(Me.GetType().BaseType.GetMethod("GetStartRow", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(Me, New Object() {pageNumber, drawArea, scale.Height}), Integer) Dim endRow As Integer = DirectCast(Me.GetType().BaseType.GetMethod("GetEndRow", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(Me, New Object() {startRow, drawArea, scale.Height}), Integer) If Me.PivotGrid.ColumnHeaderHeight <= MIN_SPACE Then startRow += 1 End If For i As Integer = startRow To endRow x = drawArea.X Dim maxHeight As Integer = 0 For j As Integer = startColumn To endColumn Dim columnWidths = DirectCast(Me.GetType().BaseType.GetField("columnWidths", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me), List(Of Integer)) Dim rowHeights = DirectCast(Me.GetType().BaseType.GetField("rowHeights", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me), List(Of Integer)) Dim elementRect As New Rectangle(x, y, columnWidths(j), rowHeights(i)) Dim printElement As RadPrintElement = Me.GetPrintElementForCell(i, j) printElement.ScaleTransform = scale Dim transformedRect As RectangleF = printElement.GetTransformedBounds(elementRect) Me.PrintElement(printElement, drawArea, elementRect, graphics) x += CInt(Math.Floor(transformedRect.Width)) maxHeight = Math.Max(maxHeight, CInt(Math.Floor(transformedRect.Height))) Next y += maxHeight Next End If End Sub End Class
How to reproduce check the attached project and video Workaround: handle the UpdateCompleted event and explicitly set the properties to true public LocalDataSourceSerializerForm() { InitializeComponent(); this.radPivotGrid1.AutoExpandColumnHeaders = false; this.radPivotGrid1.AutoExpandRowHeaders = false; this.radPivotGrid1.UpdateCompleted += radPivotGrid1_UpdateCompleted; } private void radPivotGrid1_UpdateCompleted(object sender, EventArgs e) { this.radPivotGrid1.AutoExpandColumnHeaders = true; this.radPivotGrid1.AutoExpandRowHeaders = true; }
Workaround: public class MyRadPivotGrid : RadPivotGrid { public override void SaveLayout(string fileName) { ComponentXmlSerializer ser = new ComponentXmlSerializer(this.XmlSerializationInfo); using (XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.WriteStartElement("RadPivotGrid"); ser.WriteObjectElement(writer, this); } } }
You save 2 config, one with Report filter (1), one without (2), if you load first (1), if puts report filter correctly, but if you load then (2) - report filter still as on (1). Also, if you load config with ShowFilterArea=true - it stays visible if you load another config with ShowFilterArea=true Hello Alex, While investigating the reported behavior I managed to isolate an issue in the Save/Load API of RadPivotGrid regarding the ShowFilterArea property. The default value of this property is not serialized, however this can be altered by adding a serialization meta data to the XmlSerializationInfo instance of the pivot. In this scenario the engine did not respect the added new data. Here is the feedback item and you can subscribe to it: http://feedback.telerik.com/Project/154/Feedback/Details/196273-fix-radpivotgrid-the-saveloadlayout-string-overload-does-not-use-the-radpivotg. The item is already in development and a permanent fix will be available with our next release. Regarding the empty filter descriptions, in order to serialize them one should work with a DataProviderSerializer class. Currently our engine does not save the empty filters and we will consider modifying it so that even if the collection is empty it also be serialized. I am attaching to this post a sample project with which you would be able to achieve both of your tasks. Please note that the serialization API of the LocalDataSourceProvider uses the DataContract and you would need to use our .NET 4.0 assemblies. I hope this helps. In case you need additional assistance please write here or open a support ticket. Regards, Hristo
How to reproduce: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_MouseDoubleClick(object sender, MouseEventArgs e) { PivotGridSpreadExport spreadExport = new PivotGridSpreadExport(this.radPivotGrid1); spreadExport.RunExport(@"..\..\exported-file.xlsx", new SpreadExportRenderer()); } private void Form1_Load(object sender, EventArgs e) { this.productsTableAdapter.Fill(this.nwindDataSet.Products); LocalDataSourceProvider dataProvider = new LocalDataSourceProvider(); dataProvider.ItemsSource = nwindDataSet.Products; dataProvider.BeginInit(); dataProvider.RowGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "CategoryID", GroupComparer = new GroupNameComparer() }); dataProvider.AggregateDescriptions.Add(new PropertyAggregateDescription() { PropertyName = "UnitPrice", AggregateFunction = AggregateFunctions.Sum }); dataProvider.EndInit(); this.radPivotGrid1.DataProvider = dataProvider; } } Workaround: create a custom pivot grid export object public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_MouseDoubleClick(object sender, MouseEventArgs e) { MyPivotGridSpreadExport spreadExport = new MyPivotGridSpreadExport(this.radPivotGrid1); spreadExport.RunExport(@"..\..\exported-file.xlsx", new SpreadExportRenderer()); } private void Form1_Load(object sender, EventArgs e) { this.productsTableAdapter.Fill(this.nwindDataSet.Products); LocalDataSourceProvider dataProvider = new LocalDataSourceProvider(); dataProvider.ItemsSource = nwindDataSet.Products; dataProvider.BeginInit(); dataProvider.RowGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "CategoryID", GroupComparer = new GroupNameComparer() }); dataProvider.AggregateDescriptions.Add(new PropertyAggregateDescription() { PropertyName = "UnitPrice", AggregateFunction = AggregateFunctions.Sum }); dataProvider.EndInit(); this.radPivotGrid1.DataProvider = dataProvider; } } public class MyPivotGridSpreadExport : PivotGridSpreadExport { public MyPivotGridSpreadExport(RadPivotGrid pivotGrid) : base(pivotGrid) { } public override void Initialize() { base.Initialize(); RadPivotGridElement pivotGrid = this.GetType().BaseType.GetField("pivotGrid", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this) as RadPivotGridElement; List<int> rowHeights = this.GetType().BaseType.GetField("rowHeights", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this) as List<int>; List<DescriptionBase> columnDescriptions = this.GetType().BaseType.GetField("columnDescriptions", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this) as List<DescriptionBase>; if (columnDescriptions.Count == 0) { rowHeights.Add(pivotGrid.RowHeight); columnDescriptions.Add(null); } } }
Workaround: create a custom Top10FilterOptionsDialog public Form1() { InitializeComponent(); this.radPivotFieldList1.DialogsFactory = new MyDialogsFactory(); } public class MyDialogsFactory : PivotGridDialogsFactory { public override ITop10FilterOptionsDialog CreateTop10FilterOptionsDialog() { return new MyTop10FilterOptionsDialog(); } } public class MyTop10FilterOptionsDialog : Top10FilterOptionsDialog { public override void LoadSettings(Telerik.Pivot.Core.Filtering.ITopGroupsFilter filter, string fieldName, IEnumerable<string> aggregateNames) { base.LoadSettings(filter, fieldName, aggregateNames); if (filter != null) { ((RadDropDownList)this.Controls["groupBox"].Controls["dropDownTopBottom"]).SelectedValue = filter.Selection; } } }
Workaround: use custom context menu public partial class Form1 : Form { public Form1() { InitializeComponent(); MyPivotGridContextMenu menu = new MyPivotGridContextMenu(this.radPivotGrid1.PivotGridElement); this.radPivotGrid1.PivotGridElement.ContextMenu = menu; } private void Form1_Load(object sender, EventArgs e) { this.productsTableAdapter.Fill(this.nwindDataSet.Products); LocalDataSourceProvider dataProvider = new LocalDataSourceProvider(); dataProvider.ItemsSource = nwindDataSet.Products; dataProvider.BeginInit(); dataProvider.RowGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "CategoryID", GroupComparer = new GroupNameComparer() }); dataProvider.RowGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "ProductName", GroupComparer = new GroupNameComparer() }); dataProvider.ColumnGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "ProductID" }); dataProvider.AggregateDescriptions.Add(new PropertyAggregateDescription() { PropertyName = "UnitPrice", AggregateFunction = AggregateFunctions.Sum }); dataProvider.EndInit(); this.radPivotGrid1.DataProvider = dataProvider; } } public class MyPivotGridContextMenu : PivotGridContextMenu { public MyPivotGridContextMenu(RadPivotGridElement pivotGridElement) : base(pivotGridElement) { } protected override void OnCollapseAllMenuItemClick(object sender, EventArgs e) { PivotGroupElement groupElement = this.Context as PivotGroupElement; if (groupElement != null) { RadPivotGridElement pivotGridElement = this.GetType().BaseType .GetField("pivotGridElement", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this) as RadPivotGridElement; pivotGridElement.SuspendLayout(true); if (groupElement.Data.Axis == PivotAxis.Rows) { foreach (PivotGroupNode node in pivotGridElement.GetRowGroups()) { node.Expanded = false; } } else { foreach (PivotGroupNode node in pivotGridElement.GetColumnGroups()) { node.Expanded = false; } } pivotGridElement.ResumeLayout(true, true); pivotGridElement.UpdateAfterExpandCollapse(); } } }
Workaround: private IList<PivotGroupNode> collapsedRowsNodes; private void customMenuItem_Click(object sender, EventArgs e) { PivotGridSpreadExport spreadExport = new PivotGridSpreadExport(pivotGrid); spreadExport.ExportCompleted += spreadExport_ExportCompleted; spreadExport.ExportFlatData = true; this.collapsedRowsNodes = new List<PivotGroupNode>(); PivotGridGroupTraverser rowTraverser = (PivotGridGroupTraverser)this.pivotGrid.PivotGridElement.RowScroller.Traverser.GetEnumerator(); while (rowTraverser.MoveNext()) { PivotGroupNode current = rowTraverser.Current; if (!current.Expanded) { this.collapsedRowsNodes.Add(current); current.Expanded = true; } } spreadExport.RunExport(@"..\..\export.xlsx", new SpreadExportRenderer()); } private void spreadExport_ExportCompleted(object sender, EventArgs e) { foreach (PivotGroupNode node in this.collapsedRowsNodes) { node.Expanded = false; } }
To reproduce: this.ordersTableAdapter.Fill(this.nwindDataSet.Orders); this.radPivotGrid1.RowGroupDescriptions.Add(new DateTimeGroupDescription() { PropertyName = "OrderDate", Step = DateTimeStep.Year, GroupComparer = new GroupNameComparer() }); this.radPivotGrid1.RowGroupDescriptions.Add(new DateTimeGroupDescription() { PropertyName = "OrderDate", Step = DateTimeStep.Quarter, GroupComparer = new GroupNameComparer() }); this.radPivotGrid1.RowGroupDescriptions.Add(new DateTimeGroupDescription() { PropertyName = "OrderDate", Step = DateTimeStep.Month, GroupComparer = new GroupNameComparer() }); this.radPivotGrid1.ColumnGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "EmployeeID", GroupComparer = new GrandTotalComparer() }); this.radPivotGrid1.FilterDescriptions.Add(new PropertyFilterDescription() { PropertyName = "ShipCountry", CustomName = "Country" }); this.radPivotGrid1.DataSource = this.ordersBindingSource; Workaround: public Form1() { InitializeComponent(); this.radPivotGrid1.DialogsFactory = new MyDialogsFactory(); this.radPivotFieldList1.DialogsFactory = new MyDialogsFactory(); } public class MyDialogsFactory : PivotGridDialogsFactory { public override ITop10FilterOptionsDialog CreateTop10FilterOptionsDialog() { return new MyITop10FilterOptionsDialog(); } } public class MyITop10FilterOptionsDialog : Top10FilterOptionsDialog { public override ITopGroupsFilter SelectedFilter { get { if (((RadDropDownList)this.Controls["groupBox"].Controls["dropDownFields"]).SelectedValue == null) { return null; } return base.SelectedFilter; } } }
Steps to reproduce: Just add a value filter using the ValueFilterDialog. The filter is being applied properly, however, if you read the PropertyGroupDescription to which the filter has been added and check its AggregateIndex property, it is always 0. Workaround: Use a custom ValueFilterDialog: http://docs.telerik.com/devtools/winforms/pivotgrid/dialogs/customizing-the-dialogs this.radPivotGrid1.DialogsFactory = new MyDialogsFactory(); this.radPivotFieldList1.DialogsFactory = new MyDialogsFactory(); public class MyDialogsFactory : PivotGridDialogsFactory { public override IValueFilterOptionsDialog CreateValueFilterOptionsDialog() { return new MyValueFilterOptionsDialog(); } } public partial class MyValueFilterOptionsDialog : ValueFilterOptionsDialog { public override Telerik.Pivot.Core.Filtering.IValueGroupFilter SelectedFilter { get { IValueGroupFilter filter = base.SelectedFilter; filter.AggregateIndex = ((RadDropDownList)this.Controls["groupBox"].Controls["dropDownField"]).SelectedIndex; return filter; } public override void LoadSettings(IValueGroupFilter filter, IValueGroupFilterHost filterHost, string fieldName, IEnumerable<string> aggregateNames) { base.LoadSettings(filter, filterHost, fieldName, aggregateNames); if (filter != null) { ((RadDropDownList)this.Controls["groupBox"].Controls["dropDownField"]).SelectedIndex = filter.AggregateIndex; } } } }
To reproduce: 1. Add RadPivotGrid on the form and populate it with data 2. Add 2 buttons to export to xls and xlsx formats 3. Run the form and export to xls format 4. Minimize the form. You will see that one of row is disappeared 5. Repeat the same action and you will see that a second row is disappeared. The issue if observed with both exporter providers (PivotGridSpreadExport/PivotExportToExcelML) and export with visual settings. Workaround: In the handler of the SizeChanged event clear the cached elements: void Form1_SizeChanged(object sender, EventArgs e) { this.radPivotGrid1.PivotGridElement.PivotRowsContainer.ElementProvider.ClearCache(); }