Workaround: Use the new PivotGridSpreadExport class: http://www.telerik.com/help/winforms/pivotgrid-export-srpead-export.html
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(); }
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: 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; } } }
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: 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; } } }
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: 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); } } }
Request is to have the ability preferably using a mouse drag to change the height of the column headers in the grid. We can already do that for data rows of the grid, but it is not possible currently to do the same for the header row.
Need to have the ability to resize the height of the aggregate area along with other features that will help the user see/discern the labels properly
To reproduce: Try setting the value in the CellForamting event. Workaround: class MySpreadExportRenderer : SpreadExportRenderer { public override void SetCellSelectionValue(DataType dataType, object value) { base.SetCellSelectionValue(dataType, value); if (dataType == DataType.Number) { CellRange range = ((CellSelection)this.GetCellSelection()).CellRanges.ElementAtOrDefault(0); double d; if (double.TryParse(Convert.ToString(value), out d)) { var cell = ((Worksheet)this.GetWorksheet()).Cells[range.FromIndex.RowIndex, range.FromIndex.ColumnIndex]; cell.SetFormat(new CellValueFormat("#,##0.00")); cell.SetValue(d); } } } }
How to reproduce: check the attached project and screenshots, the correct items are shown in screenshot correct-items-calculated-field.jpg Workaround: public partial class Form1 : Form { private LocalDataSourceProvider provider; public Form1() { InitializeComponent(); //Setup pivot and add calculated field //Workaround this.radPivotFieldList1.ValuesControl.CreatingVisualListItem += ValuesControl_CreatingVisualListItem; } private void ValuesControl_CreatingVisualListItem(object sender, CreatingVisualListItemEventArgs args) { args.VisualItem = new MyPivotFieldListVisualItem(this.radPivotFieldList1.ViewModel); } } public class MyPivotFieldListVisualItem : PivotFieldListVisualItem { FieldListViewModel viewModel; public MyPivotFieldListVisualItem(FieldListViewModel viewModel) : base(viewModel) { this.viewModel = viewModel; } protected override void UpdateContextMenu() { base.UpdateContextMenu(); PivotFieldListItemButton button = (PivotFieldListItemButton)typeof(PivotFieldListVisualItem).GetField("button", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(this); string providerName = this.viewModel.DataProvider != null ? this.viewModel.DataProvider.GetType().FullName : String.Empty; if (this.Data == null) { return; } if (this.Data.DataBoundItem is Value && !(providerName.Contains("Xmla") || providerName.Contains("Adomd"))) { for (int i = 0; i < 5; i++) { button.Items.RemoveAt(i); } } } }
How to reproduce: Me.RadPivotGrid1.DataSource = Nothing Workaround: DirectCast(Me.RadPivotGrid1.DataProvider, LocalDataSourceProvider).ItemsSource = Nothing Dim viewModel = Me.RadPivotGrid1.PivotGridElement.GetType().GetField("viewModel", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me.RadPivotGrid1.PivotGridElement) viewModel.GetType().GetProperty("DataProvider").SetValue(viewModel, Nothing)
How to reproduce: see the attached video Workaround: public partial class Form2 : Form { public Form2() { InitializeComponent(); this.radPivotFieldList1.DragDropService = new CustomPivotFieldListDragDropService(this.radPivotFieldList1); } private void Form2_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'nwindDataSet.Orders' table. You can move, or remove it, as needed. this.ordersTableAdapter.Fill(this.nwindDataSet.Orders); } } public class CustomPivotFieldListDragDropService : PivotFieldListDragDropService { private RadPivotFieldList fieldList; private Telerik.WinControls.UI.PivotFieldList.FieldPayload payload; public CustomPivotFieldListDragDropService(RadPivotFieldList fieldList) : base(fieldList) { this.fieldList = fieldList; } protected override void PerformStart() { base.PerformStart(); Telerik.WinControls.UI.PivotFieldList.IField draggedField = this.GetField(this.Context); if (draggedField == null) { this.Stop(false); return; } this.payload = new Telerik.WinControls.UI.PivotFieldList.FieldPayload(draggedField); } protected override void OnPreviewDragOver(RadDragOverEventArgs e) { RadElement targetElement = this.DropTarget as RadElement; Telerik.WinControls.UI.PivotFieldList.IField targetField = this.GetField(targetElement); if (targetElement != null && targetElement.ElementTree.Control == this.fieldList.ReportFiltersControl && this.payload != null) { foreach (Telerik.WinControls.UI.PivotFieldList.IField field in this.fieldList.ViewModel.Filters) { if (field.FieldInfo == payload.DraggedField.FieldInfo && this.Context is TreeNodeElement )) { e.CanDrop = false; this.payload.SetDestination(null); this.payload.RemoveFromSource = false; return; } } } base.OnPreviewDragOver(e); } private Telerik.WinControls.UI.PivotFieldList.IField GetField(object context) { RadListVisualItem listItem = context as RadListVisualItem; TreeNodeElement treeItem = context as TreeNodeElement; PivotFieldListItemButton button = context as PivotFieldListItemButton; if (button != null) { listItem = button.Owner; } Telerik.WinControls.UI.PivotFieldList.IField field1 = null, field2 = null; if (listItem != null && listItem.Data != null) { field1 = listItem.Data.DataBoundItem as Telerik.WinControls.UI.PivotFieldList.IField; } if (treeItem != null && treeItem.Data != null) { field2 = treeItem.Data.DataBoundItem as Telerik.WinControls.UI.PivotFieldList.IField; } return field1 ?? field2; } }
The error is reproducible in the First look example of RadPivotGrid:
The "Sort" item doesn't seem to be relevant for the report filter. It should be removed from the menu items. However, for the "Hide" item it can be added logic for removing the filter: