简体   繁体   English

Ag-Grid-服务器端行模型params.failCallback

[英]Ag-Grid - serverside row model params.failCallback

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. 我们已经实现了IServerSideDatasource,并且,如果服务器出错,则按照建议调用params.failCallback。

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. “ onRowDataChanged”事件将触发,但它没有有关事件状态的信息。

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. 理想情况下,我想通过ag-grid事件来处理此问题,而不是从IServerSideDatasource甚至http客户端抛出我自己的错误。

Is this possible? 这可能吗?

I'm using a custom eventListener to catch failCallback calls and it works pretty well 我正在使用自定义的eventListener来捕获failCallback调用,并且效果很好

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: 在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…} onServerFailCallback,{类型:“ failCallback”,api:GridApi,columnApi:ColumnApi,错误:错误:堆栈跟踪中fetchData()内部错误…}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM