Hello,
I am working with calculated fields in pivot tables and I would like to know if it is possible to keep the field chosen even after the page is refreshed. I realized that once you create a new field and refresh the page, the field does not disappear but it does not stay selected so the column in the table does not appear.
Is it possible therefore, to keep it chosen and have the column remained in the table? Is there any table configuration that allows this?
Thanks and regards,
Hi Oscar,
To maintain the calculated field even after refreshing the page, please create the calculated fields using calculatedFieldSettings property through code-behind at sample itself. Please refer the below code example.
Code Example:
|
this.dataSourceSettings = { values: [{ name: 'In_Stock', caption: 'In Stock' }, { name: 'Total', caption: 'Total Units', type: 'CalculatedField' }], calculatedFieldSettings: [ { name: 'Total', formula: '"Sum(In_Stock)"+"Sum(Sold)"' } ] } |
Meanwhile, we have prepared a sample for your reference.
Sample: https://stackblitz.com/edit/angular-qu49e8?file=app.component.ts,app.component.html
Screenshot:
Total Units calculated field remain in the column after page refreshing/ component refreshing.
Please refer the UG document to know more about calculatedFieldSettings property.
Document: https://ej2.syncfusion.com/angular/documentation/pivotview/calculated-field/
Please let us know if you have any concerns.
Regards,
Angelin Faith Sheeba
Hello Angelin,
Thanks for your quick response and help.
Perhaps with what you send me it can be done but what we want is that when the user manually creates a calculated field we need to keep checked and therefore it remains as a column even if the page is refreshed.
We cannot do this by code since it is needed a dynamic behavior when the user creates his own calculated field. We cannot preconfigure it from code.
Current behaviour:
2. When the field is created it is automatically checked (and appears like a column in the table).
3. Once the user refresh the page, the field is automatically unchecked removing from the table as column.
Our needed behaviour is to mantain the field checked and do not remove as column from table by default when refreshing the page.
I hope this could be possible by changing settings from dataSourceSettings.
Thanks again and regards.
Hi Oscar,
Using enablePersisitence property, you can maintain the dynamically created calculated field after refreshing the page. Please refer the below code example.
Code example:
|
<ejs-pivotview enablePersistence="true"> </ejs-pivotview>
|
Meanwhile, we have prepared a sample for your reference.
Sample: https://stackblitz.com/edit/angular-qu49e8-vbkqvc?file=app.component.ts,app.component.html
Screenshot:
Please refer the UG document to know more about enablePersisitence property.
Document: https://ej2.syncfusion.com/angular/documentation/pivotview/state-persistence/
Please let us know if you have any concerns.
Regards,
Angelin Faith Sheeba