Add/remove axis programmatically
Hi,
Is there the possibility to programmatically add or remove a row, column or filter field in the PivotTable component?
The use case is: I need to have a "fast filter" (for instance, Year) that is external with respect to a pivot table. Just imagine a text box in which the user writes the year to use to filter the data. When the input is complete and the user presses a button, the button calls a method that inserts (or removes) into the PivotTable (or PivotFieldList) this filter (something like "Pivot.PivotViewFilters.Add(myNewFilter)".
This may also be needed to add (or remove) a row or column dimension with multiple values selected (i.e., I have a dimension with dates, and the users select which dates to see in rows).
From the documentation it seems that it is not currently supported, am I wrong? Will it be in the future?
Or where can I look at an example?
Thank you.
Kind regards,
Riccardo Zucchetto
SIGN IN To post a reply.
5 Replies
RZ
Riccardo Zucchetto
April 29, 2020 09:37 AM UTC
Hi,
Kind regards,
I may have found a way to do it, but it is not working.
The code is:
PivotViewColumn pvc = new PivotViewColumn();
pvc.Name = "[Dimension].[Dimension - Field]";
pvc.Caption = "Caption";
Pivot.DataSourceSettings.Columns.Add(pvc);
Pivot.Refresh();
The "Columns" field, with Intellisense, has Count = 1, so the column has been correctly added; however, neither in the built-in field list nor in the pivot table there is anything on the column axis.
So I will wait for your response to know whether it is supported by the component and how to do it.
Kind regards,
Riccardo Zucchetto
SN
Sivamathi Natarajan
Syncfusion Team
April 29, 2020 11:00 AM UTC
Hi Riccardo,
We regret you to let you know that your requirement couldn’t be achievable in pivot table component. But, we have logged the requirement as feature task which will be available in any of our upcoming release. You can track the task in the following link.
And, we will inform you once we have implemented the feature. Until then we appreciate your patience.
Regards,
Sivamathi.
Sivamathi.
RZ
Riccardo Zucchetto
April 29, 2020 11:04 AM UTC
Hi Sivamathi,
Thank you very much.
I will track the task.
Riccardo
SN
Sivamathi Natarajan
Syncfusion Team
April 30, 2020 06:18 AM UTC
Hi Riccardo,
Thanks for the reply.
Regards,
Sivamathi.
Sivamathi.
MM
Manikandan Murugesan
Syncfusion Team
October 5, 2021 10:35 AM UTC
Hi Riccardo,
You can add or remove the fields programmatically by using Pivot Table reference. Please refer the following code example below.
Code Example:
|
public void AddRow()
{
Rows.Add(new PivotViewRow { Name = "Products" });
this.Pivot.DataSourceSettings.Rows = Rows;
} |
Meanwhile, we have prepared a sample for your reference.
Please let us know if you have any concerns.
Regards,
Manikandan
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
-
RZ Riccardo Zucchetto
- Apr 28, 2020 04:09 PM UTC
- Oct 5, 2021 10:35 AM UTC