We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Enable to reset the datasource with anothers datas

Thread ID:

Created:

Updated:

Platform:

Replies:

144362 May 2,2019 02:22 PM UTC May 3,2019 12:45 PM UTC JavaScript - EJ 2 4
loading
Tags: PivotView
Foulont Gaetan
Asked On May 2, 2019 02:22 PM UTC

Hello, 

I have this PivotView congured like that : 

                    pivotGridObj = new ej.pivotview.PivotView({
                        dataSource: {
                            enableSorting: true,
                            columns: [],
                            rows: [],
                            valueSortSettings: {
                                headerDelimiter: ' - '
                            },
                            data: ej.data.DataUtil.parse.isJson($scope.data),
                            expandAll: false,
                            formatSettings: [],
                            values: [],
                            filters: [],
                        },
                        showFieldList: true,
                        displayOption: {
                            view: 'Chart'
                        },
                        chartSettings: {
                            chartSeries: {
                                type: 'Column'
                            },

                        },
                        //showToolbar: true,
                        allowCalculatedField: true,
                        //toolbar: ['Chart'],
                        width: '99%',
                        height: '100%',
                    });


                    pivotGridObj.appendTo('#' + id);

How Can I reset the datasource from this specific PivotGridObj with completely another data structure ?

When I try to reset this PivotGrid with this code :

                    pivotGridObj = document.getElementById(id).ej2_instances[0];
                    pivotGridObj.dataSource = {
                        enableSorting: true,
                        columns: [],
                        rows: [],
                        valueSortSettings: {
                            headerDelimiter: ' - '
                        },
                        data: ej.data.DataUtil.parse.isJson($scope.data),
                        expandAll: false,
                        formatSettings: [],
                        values: [],
                        filters: [],
                    };

It doesnt work at all. I just retrieve my precedent field list with my actual new properties.


Here it is Before with initial data :


And After i Try to reset the datasource with other datas :
the data structure is not the same, ie : in new datas I don't have 'OptionPossible' property...



Coud you please help me ?

Thx

Sabaridass Ramamoorthy [Syncfusion]
Replied On May 3, 2019 07:10 AM UTC

Hi Foulont, 

You can refresh “fieldlist” by using below code snippet when refreshing the data. 

Code Snippet: 
refreshBtn.element.onclick = function () { 
    pivotGridObj.engineModule.fieldList = {}; 
} 
 

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

Regards, 
Sabaridass R 


Foulont Gaetan
Replied On May 3, 2019 07:27 AM UTC

Hello, 

Thanks for your replay but it doesnt work if I change completly the structure of the json when I refresh.

See the stackblitz below:




Foulont Gaetan
Replied On May 3, 2019 07:27 AM UTC

Hi Foulont, 

You can refresh “fieldlist” by using below code snippet when refreshing the data. 

Code Snippet: 
refreshBtn.element.onclick = function () { 
    pivotGridObj.engineModule.fieldList = {}; 
} 
 

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

Regards, 
Sabaridass R 


Hello, 

Thanks for your replay but it doesnt work if I change completly the structure of the json when I refresh.

See the stackblitz below:



Sabaridass Ramamoorthy [Syncfusion]
Replied On May 3, 2019 12:45 PM UTC

Hi Foulont, 

Thanks for the reply. 

You need to remove row, column and value fields which are not included in the data. You can remove fields by using following code snippet. 
Code Snippet: 
   var pivotGridObj = new ej.pivotview.PivotView({ 
        enginePopulating: function(args) { 
          var report = {}; 
          report[0] = args.dataSource.rows; 
          report[1] = args.dataSource.columns; 
          report[2] = args.dataSource.values; 
          report[3] = args.dataSource.filters; 
          var pos = 0; 
          while (pos < 4) { 
            if (report[pos]) { 
              for (var cnt = 0; cnt < report[pos].length; cnt++) { 
                if (Object.keys(args.dataSource.data[0]).indexOf(report[pos][cnt].name) == -1) { 
                  report[pos].splice(cnt, 1); 
                  cnt--; 
                } 
              } 
            } 
            pos++; 
          } 
        } 
    }); 
    pivotGridObj.appendTo('#PivotView'); 
 
 

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

Regards, 
Sabaridass R 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon