Catch errors from the backend

Hi,

I use the pivot view component (React).

I would like to add a code in order to catch the errors from the backend.

This is my code :


getDataSourceSettings():IDataOptions {

        ...

        let remoteData: DataManager = new DataManager({

            url: ...

            adaptor: new WebApiAdaptor,

            ...

        });

        let dataSourceSettings: IDataOptions = {

            dataSource: remoteData as DataManager,

            type: 'JSON',

            ...

        };

        return dataSourceSettings;

    }

...

<PivotViewComponent

id='PivotView'

        dataSourceSettings={this.getDataSourceSettings()}

        ....

The code works but my question is : where to add the code in order to catch errors from the backend api ?.

Thanks in advance !


5 Replies

AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team June 15, 2022 06:25 PM UTC

Hi Jorge,


Please refer the below code example to catch the error.


Code Example:

let remoteData = new DataManager({

  url: 'https://bi.syncfusion.com/northwindservice/api/orders',

  adaptor: new WebApiAdaptor(),

  crossDomain: true,

})

  .executeQuery(new Query())

  //If there is any error in the backend, you can catch the error here.

  .then((e=> {

    pivotObj.dataSourceSettings.dataSource = e.result;

  });

 


Moreover, you can use the actionFailure event to catch the error of current UI action.


Meanwhile, we have prepared a sample for your reference.

Sample: https://stackblitz.com/edit/react-jpemrq-iy3jxs?file=index.js


Please refer the below UG document for how to render the Pivot table.

Document: https://ej2.syncfusion.com/react/documentation/pivotview/filtering/#actionfailure


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


Regards,

Angelin Faith Sheeba.



JV JORGE V June 21, 2022 10:38 PM UTC

Hi,

I tried to add actionFailure in pivotViewComponent but it doesn't compile (others properties as drill, enginePopulated, toolbarRender works).

I use :

 "@syncfusion/ej2-react-pivotview": "19.2.46",




Any help is much appreciated.

Jorge



AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team June 22, 2022 11:26 AM UTC

Hi Jorge,


ActionFailure event support is available from the version ( v19.4.38) in our pivot table component. So, please update your packages to the latest version to resolve the reported issue at your end.


Meanwhile, we have prepared a sample for your reference. Please find it from below link.

Sample: https://stackblitz.com/edit/react-bxebag?file=index.js


Please let us know if you have any concerns.


Regards,

Angelin Faith Sheeba



JV JORGE V June 27, 2022 05:02 PM UTC

Hi,

Thank you, with the following line in package.json it was possible to add the method actionFailure.

"@syncfusion/ej2-react-pivotview": "^20.1.61",


  • I have a problem with new version but I'am going to add other post.


Regards,

Jorge



AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team June 28, 2022 10:20 AM UTC

Hi Jorge,


Please let us know if you have any other queries. We are always happy to assist you.


Regards,

Angelin Faith Sheeba.


Loader.
Up arrow icon