BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi,
I am using Pivot Table table Toolbar to save/load reports in current websocket session.
The feature that I need is to save user's pivot table configurations - what you call as "report" to a database; and when user come back, load the saved reports to the PivotTable.
I've not found evident API in SfPivotView/Toolbar.
Is it possible to achieve that ? If so, can you please provide a sample ?
Thx!
Yi
Hi Yi Han,
To store and load reports using toolbar options, we don't use API. We can save and load the pivot report at the sample level using the SaveReport and LoadReport events. Please refer the below code example and sample.
Code Example:
<SfPivotView TValue="ProductDetails"> <PivotViewEvents TValue="ProductDetails" SaveReport="savereport" LoadReport="loadreport"></PivotViewEvents> </SfPivotView>
@code { //save the report using SaveReport event public void savereport(SaveReportArgs args) { var i = 0; bool isSaved = false; for (i = 0; i < this.reportName.Count; i++) { if (this.reportName[i] == args.ReportName) { this.report[i] = args.Report; isSaved = true; } } if (args.Report != null && !(isSaved)) { this.report.Add(args.Report); this.reportName.Add(args.ReportName); }
}
//to load the selected report. public void loadreport(LoadReportArgs args) { var i = 0; var j = 0; for (i = 0; i < this.reportName.Count; i++) { if (this.reportName[i] == args.ReportName) { j = i; } } this.pivot.LoadPersistDataAsync(this.report[j]); } } |
Meanwhile, we have prepared a sample for your reference.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PivotTable1533777045
Please see the below UG document for more information on the “toolbar” events.
Document: https://blazor.syncfusion.com/documentation/pivot-table/tool-bar#events
Regards,
Angelin Faith Sheeba
Hi Angelin Faith Sheeba
Thx for your reply.
... But this does fit my requirement. The way your sample is doing, does not persists the report configuration. i.e, you close the browser tab then open a new one, the pivot table report is gone - user have to reconfigure the report. <-- not handy!
What I want, as said in the initial question, is saving the report configuration in a persistent data store, each time the user open pivot table page, programmatically rebuild the report automatically. <- the functionality that is possible in ASPNET Core EJ2 (https://www.syncfusion.com/forums/160976/save-and-load-report-of-pivot-report-with-web-api )
Is this more clear?
Thx!
Yi
Hi Yi Han,
We are validating this query at our end and will provide further details within two business days (Dec 12, 2022).
Regards,
Angelin Faith Sheeba.
Hi Yi Han,
We are preparing sample as per your requirement and we will provide further details tomorrow (Dec 13, 2022).
Hi Yi Han
We've prepared a sample for saving and loading reports from a SQL Server database based on your requirements. For more information, please see the sample link below.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Pivot-DB-415759584
Please let us know if you have any concerns.
Regards,
Rajeshkannah G.
Hi Rajeshkannah ,
thanks for the sample.
I am also trying using bool: EnablePersistence
https://blazor.syncfusion.com/documentation/pivot-table/state-persistence
with your above attached sample, add EnablePersistence="true" ID="hello-world" to your pivotview
I do see local storage is used - but the persistent feature does not work. i.e, refresh the page & move to another page then come back -> expected state is lost!
Hi Yi,
We created a Pivot Table sample that saves and loads reports from a database based on your requirements, which we shared in our previous update. So, even if EnablePersistense is enabled, the Pivot Table will always load the last saved report from the database, because the persistence report is always saved in the browser's local storage. You can, however, retrieve the persisted data and load the Pivot table by using the Destroyed event and saving the persist data report to Database. Please see the code example below.
Code Example
<SfPivotView> <PivotViewEvents TValue="Order" Destroyed=="Destroyed" > </PivotViewEvents> </SfPivotView>
public async void Destroyed() { string persistReport = await Pivot.GetPersistDataAsync(); SaveReportToDB("Sample Report",persistReport ); }
|
Meanwhile we have prepared a sample for your reference.
Kindly let us know if you have any concerns.
Regards,
Rajeshkannah G