How can i make my own table data

How can i open empty and make my own data entry with column name and rows data.i want to save that as json and load as json


1 Reply

AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team June 30, 2022 03:41 PM UTC

Hi Asim,


Please refer the below code example to save the current pivot report as JSON file in the desired path and load back to the pivot table based on your need.


Code Example:

function ondataBound(args) {

        var pivotTableObj = document.getElementById('pivotview').ej2_instances[0];

        var dataSource = JSON.parse(pivotTableObj.getPersistData()).dataSourceSettings;

        var a = document.getElementById('save');

        var mime_type = 'application/octet-stream'; // text/html, image/png, et c

        a.setAttribute('download', 'pivot.JSON');

        a.rel='nofollow' href = 'data:'+ mime_type +';base64,'+ btoa(JSON.stringify(dataSource) || '');

        document.getElementById('files').addEventListener('change', readBlob, false);

    }

 

    function readBlob(args) {

        var files = document.getElementById('files').files;

        var file = files[0];

        var start = 0;

        var stop = file.size - 1;

        var reader = new FileReader();

        reader.onloadend = function(evt) {

            if (evt.target.readyState == FileReader.DONE) {

                var pivotTableObj = document.getElementById('pivotview').ej2_instances[0];

                pivotTableObj.dataSourceSettings = JSON.parse(evt.target.result);

            }

        };

        var blob = file.slice(start, stop + 1);

        reader.readAsBinaryString(blob);

    }


Meanwhile, we have prepared a sample for your reference.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PivotTable-965298703


Please let us know if you have any concerns.


Regards,

Angelin Faith Sheeba.


Loader.
Up arrow icon