最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Ag-Grid - serverside row model params.failCallback - Stack Overflow

programmeradmin2浏览0评论

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 remended.

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 remended 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?

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 remended.

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 remended 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?

Share Improve this question asked Jun 21, 2018 at 16:22 LeeLee 2962 silver badges16 bronze badges 5
  • 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 Commented Jun 13, 2019 at 13:52
  • Sorry - no - never did solve it – Lee Commented Jun 14, 2019 at 14:06
  • @SMarello problem still exists..... did you find a solution other then a custom eventListener? – lolplayer101 Commented Oct 22, 2019 at 9:57
  • @lolplayer101 Nope sorry, custom eventListener worked fine in my situation. – SMarello Commented Oct 23, 2019 at 12:29
  • 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 ponent. – Jon Vote Commented Dec 14, 2020 at 0:17
Add a ment  | 

1 Answer 1

Reset to default 5

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…}

发布评论

评论列表(0)

  1. 暂无评论