How can I save my Field settings including calculated fields for Pivot Table

How can I save my Field settings including calculated fields for Pivot Table. When using get persisted data i am getting complete datasource which was used earlier. I only want to load the field settings and calculations i did earlier. I want data should load fresh, not the one i used at the time of saving.

How this can be achieved?

3 Replies

SN Sivamathi Natarajan Syncfusion Team February 21, 2020 12:37 PM UTC

Hi Ankit, 
 
Thanks for contacting Syncfusion support. 
 
We would like to inform that the requirement can be achieved using following code example. 
 
Code Example: 
 
<div class="col-lg-3 property-section"> 
    <table id="property" title="Properties" style="width: 100%"> 
        <tbody> 
            <tr style="height: 50px"> 
                <td> 
                    @Html.EJS().Button("save").Content("SAVE").IsPrimary(true).Render() 
                </td> 
            </tr> 
            <tr style="height: 50px"> 
                <td> 
                    @Html.EJS().Button("load").Content("LOAD").IsPrimary(true).Render() 
                </td> 
            </tr> 
        </tbody> 
    </table> 
</div> 
 
<script> 
 
    document.getElementById("save").addEventListener('click', function () { 
        var pivotObj = document.getElementById('pivotview').ej2_instances[0]; 
        var dataSource = JSON.parse(pivotObj.getPersistData()).dataSourceSettings; 
        dataSource.dataSource = []; 
        localStorage.pivotReport = JSON.stringify(dataSource); 
    }); 
 
    document.getElementById("load").addEventListener('click', function () { 
        var pivotObj = document.getElementById('pivotview').ej2_instances[0]; 
        var dataSource = JSON.parse(localStorage.pivotReport); 
        dataSource.rows = []; 
        dataSource.columns = []; 
        dataSource.values = []; 
        dataSource.filters = []; 
        dataSource.dataSource = [ 
            { 'Sold': 31, 'Amount': 52824, 'Country': 'France', 'Year': 'FY 2015' }, 
            { 'Sold': 51, 'Amount': 86904, 'Country': 'France', 'Year': 'FY 2015' }, 
            { 'Sold': 90, 'Amount': 153360, 'Country': 'Germany', 'Year': 'FY 2017' }, 
            { 'Sold': 25, 'Amount': 42600, 'Country': 'France', 'Year': 'FY 2015' }, 
            { 'Sold': 27, 'Amount': 46008, 'Country': 'Ausralia', 'Year': 'FY 2016' }]; 
        pivotObj.dataSourceSettings = dataSource; 
    }); 
</script> 
 
Meanwhile, we have prepared a sample for your reference. Kindly check the below sample link. 
 
 
We hope the above sample meets your requirement. 
 
Regards, 
Sivamathi. 
 



AN Ankit February 21, 2020 01:31 PM UTC

Thank you for your support. I got my think working.


MM Manikandan Murugesan Syncfusion Team February 24, 2020 09:56 AM UTC

Hi Ankit, 

Thanks for your response. 

Please let us know if you need any further assistance on this. 

Thanks, 
Manikandan. 


Loader.
Up arrow icon