Pivot Computation Info Items loose visibilty after Reset pivot data

I have created an action that modifies the RowPivotItems, ColumnPivotItems and PivotComputationInfoItems when selected. The Invoke looks like this:

protected override void Invoke(object parameter)
        {
            if (parameter is RoutedEventArgs)
            {
                var eventArgs = parameter as RoutedEventArgs;
                var sourceCmBox = eventArgs.OriginalSource as ComboBoxAdv;
                if (sourceCmBox != null)
                {
                    Target.ResetPivotData();

                    var schemaDesigner = (PivotSchemaDesigner)(this.Target as PivotGridControl).GetType().GetProperty("SchemaDesigner", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this.Target, null);
                    if (schemaDesigner != null)
                    {
                        Target.PivotFields.Clear();
                        Target.PivotCalculations.Clear();
                        Target.PivotRows.Clear();
                        Target.PivotColumns.Clear();

                        schemaDesigner.InitializePivotTableList();
                        schemaDesigner.PivotCalculationList.Visibility = Visibility.Visible;

                        Target.RowPivotsOnly = false;
                    }
                }
          }
     }
I then run another method that updates the RowPivotItems, ColumnPivotItems and PivotComputationInfoItems. The binding is successful as I can see the correct collection items when debugging Target. However, the PivotGridControl.PivotCalculations hides all PivotComputationInfoItems and future ones that I add.

Have i missed a setting somewhere? Thank you

6 Replies

DV Duraimurugan Vedagiri Syncfusion Team March 19, 2020 01:03 PM UTC

Hi Kelby ,

Thanks for using syncfusion products.

We have analyzed the reported issue with your given code snippet. When you call the Target.ResetPivotData() method it will reset the all pivot items including itemsource. Therefore, if you add the pivot item in PivotSchemaDesigner the grid did not populate any data.So, we suggest you add the ItemSource after calling the Target.ResetPivotData() method.

Sample link : https://www.syncfusion.com/downloads/support/forum/152536/ze/PIVOTS~1282452851

Video link : https://www.syncfusion.com/downloads/support/forum/152536/ze/PivotSrRec1227128227

Please let us know if we misunderstood your query.

Regards,
Durai


KT Kelby Tansley March 19, 2020 03:31 PM UTC

Hi,

I have done this and it is not working. 

When debugging I see that PivotCalculations list is updated in this.Target with the correct count value and the schemaDesigner.PivotCalculationList has a count value of 0. This tells me that schemaDesigner.InitializePivotTableList(); is not doing anything.

When adding fields to the PivotCalculationList ListBox they update the pivot grid but do not display in the ListBox.


KT Kelby Tansley March 19, 2020 03:44 PM UTC

Ive seemed to find a solution but do not know what this may impact.

var schemaDesigner = (PivotSchemaDesigner)(this.Target as PivotGridControl).GetType().GetProperty("SchemaDesigner", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this.Target, null);
                    if (schemaDesigner != null)
                    {
                        schemaDesigner.PivotCalculationList.ItemsSource = schemaDesigner.PivotControl.PivotCalculations;
                    }

Also, no need to run the schemaDesigner.InitializePivotTableList();


DV Duraimurugan Vedagiri Syncfusion Team March 20, 2020 12:47 PM UTC

Hi Kelby,

Thanks for you update.

 
Query 
Response 
When debugging i see that PivotCalculations list is updated in this.Target with the correct count value and the schemaDesigner.PivotCalculationList has a count value of 0. 
We are unable to reproduce at our end. By default, if Target (pivotgrid) is updated, the schemaDesigner PivotCalculationList value also updated. 
schemaDesigner.InitializePivotTableList() is not doing anything. 
This method will initialize only pivottablelist based on the given item source (such as Shape, color, etc.,). This method doesn’t add any items into the target. 
var schemaDesigner = (PivotSchemaDesigner)(this.Target as PivotGridControl).GetType().GetProperty("SchemaDesigner", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this.Target, null); 
if (schemaDesigner != null) 
{ 
schemaDesigner.PivotCalculationList.ItemsSource = schemaDesigner.PivotControl.PivotCalculations; 
} 
There is no need to set the itemsource values into the PivotCalcualtionList. As we said earlier, if the PivotCalculations values are added in the target property, calculation values are added into the PivotCalcualtionList automatically. 
























  



Could you please modify our shared sample with issue reproducible, it would be very helpful to provide the solution earliest.

Regards,
Durai



KT Kelby Tansley March 20, 2020 12:58 PM UTC

Try running an action that clears the Target item source, then update the Target item source in the viewmodel and then run another action that does this:
var schemaDesigner = (PivotSchemaDesigner)(this.Target as PivotGridControl).GetType().GetProperty("SchemaDesigner", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this.Target, null); 
if (schemaDesigner != null) 
{ 
//Break here
} 

You will see that schemaDesigner.PivotCalculationList is an empty collection.


DV Duraimurugan Vedagiri Syncfusion Team March 24, 2020 01:51 PM UTC

 Hi Kelby,

Thanks for you update.

We have analyzed the reported issue "SchemaDesigner.PivotCalcualtionList is will be a empty collection" but we are unable to reproduce at our end. Please refer the below code snippet, sample and video for your reference.

Code Snippet

 
protected override void Invoke(object parameter) 
{ 
    if (parameter is RoutedEventArgs) 
    { 
        RoutedEventArgs eventArgs = parameter as RoutedEventArgs; 
        var sourceCmBox = eventArgs.OriginalSource as ComboBox; 
        if (sourceCmBox != null) 
        { 
            if (sourceCmBox.SelectedItem.ToString() == "Action1") 
                //Clear the Target itemsource. 
                (Target.ItemSource as ProductSalesCollection).Clear(); 
            else if (sourceCmBox.SelectedItem.ToString() == "Action2") 
            { 
                //Update the Target itemsource. 
                Target.ItemSource = ProductSales.GetSalesData(); 
                var schemaDesigner = (PivotSchemaDesigner)(this.Target as PivotGridControl).GetType().GetProperty("SchemaDesigner", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this.Target, null); 
                if (schemaDesigner != null) 
                { 
                    schemaDesigner.InitializePivotTableList(); 
                    if (schemaDesigner.PivotCalculationList != null && schemaDesigner.PivotCalculationList.Items.Count > 0) 
                    { 
 
                    } 
                } 
            } 
        } 
    } 
} 


 

Video link : https://www.syncfusion.com/downloads/support/forum/152536/ze/PIvotGridREC549650654

If our replication procedure different from your requirement, please let us know your availability for meeting and we will make every effort to have this scheduled on a date and time of your convenience.

Please let us know if you have any concerns.

Regards,
Durai
 


Loader.
Up arrow icon