Completed
Last Updated: 03 Jun 2016 06:01 by ADMIN
ADMIN
Hristo
Created on: 02 Jun 2016 06:57
Category: PivotGrid
Type: Bug Report
0
FIX. RadPivotGrid - the vertical scrollbar is not properly updated after collapsing all groups using the context menu
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();
        }
    }
}
0 comments