getPersistData without the data ( dataSourceSettings.dataSource )

We use getPersistData in the Pivot table in order to persists its settings. We do not need the data though as it might become very large with 100k records or so.


Is it possible to fetch everything return by getPersistData but without the data array (dataSourceSettings.dataSource ) .


I understand we can remove it but, if does not need to be processed by the getPersistData  method it might be faster and more efficient.


Thank you


1 Reply

AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team April 21, 2022 04:16 PM UTC

Hi Thierry,


Using dataBound and load event, you can save and load the report from localStorage instead of using getPersistData. Please refer the below code example.


Code Example:


                                                                                                 

dataBound: function (args) {

    if (pivotObj) {

      obj = 'PivotTable' + pivotObj.element.id;

      var pivotTableObj = JSON.parse(

        document.querySelector('#PivotView').ej2_instances[0].getPersistData()

      );

      if (pivotTableObj) {

        pivotTableObj.dataSourceSettings.dataSource = [];

      }

      localStorage[obj] = JSON.stringify(pivotTableObj);

    }

  },

  load: function (args) {

    obj = 'PivotTable' + pivotObj.element.id;

    if (obj && localStorage[obj]) {

      var data = JSON.parse(localStorage[obj]);

      data.dataSourceSettings.dataSource =

        pivotObj.dataSourceSettings.dataSource;

      pivotObj.dataSourceSettings = data.dataSourceSettings;

    }

  },

 

 


Meanwhile, we have prepared a sample for your reference.


Sample: https://stackblitz.com/edit/nlxdti-wzlhql?file=index.js


Please let us know if you have any concerns.


Regards,

Angelin Faith Sheeba.


Loader.
Up arrow icon