5
votes

We're using the enterprise server side row model to fetch data from the server. We've implemented the IServerSideDatasource and, if the server errors, we call params.failCallback as recommended.

However, nothing happens on the grid. The loading spinner still is visible and there's no notification to the user about anything going wrong.

The 'onRowDataChanged' event fires, but it has no information about the status of the event.

Is there a recommended way to notify the user about the failure? Ideally I'd like to deal with this through ag-grid events rather than throw my own errors from the IServerSideDatasource or even the http client.

Is this possible?

1
I know this question is 1 year old but I'm having the exact same issue. Did you figure out how to work with the failCallback? - SMarello
Sorry - no - never did solve it - Lee
@SMarello problem still exists..... did you find a solution other then a custom eventListener? - lolplayer101
@lolplayer101 Nope sorry, custom eventListener worked fine in my situation. - SMarello
In case someone finds it helpful...the eventListener is not working for me, but what does work is to declare an error event in the datasource and subscribe to this in the calling component. - Jon Vote

1 Answers

4
votes

I'm using a custom eventListener to catch failCallback calls and it works pretty well

In my main class:

onGridReady = params => {
    this.gridApi = params.api;
    this.gridApi.addEventListener('failCallback', this.onServerFailCallback);
    this.gridApi.setServerSideDatasource(MyRemoteDataSource);
 };

onServerFailCallback = params => {
    console.error('onServerFailCallback', params); 
 }

In MyRemoteDatasource:

class MyRemoteDatasource{
    getRows(params) {
        fetchData(params).then(
        response => {     
            params.successCallback(response.data);
        }, 
        error => {    
           params.failCallback();
           params.parentNode.gridApi.dispatchEvent({
               type: 'failCallback',
               api: params.parentNode.gridApi,
               columnApi: params.parentNode.columnApi,
               error: error
           });
        });
    }
}

output:

onServerFailCallback, {type: "failCallback", api: GridApi, columnApi: ColumnApi, error: Error: Error inside fetchData() at stack trace…}