LyteNyte Grid logo for light mode. Links back to the documentation home page.
Server Data Loading

Handling Load Failures

Network requests can fail at any time, that's an inherent part of client-server communication. The LyteNyte Grid server data source provides simple mechanisms to recover from request errors, making it easy to retry failed requests.

Handling Initial Request Failure

When the server data source initializes, it sends an initial data request to the server. If this request fails, LyteNyte Grid can't determine which data slices to re-request because none have loaded. The simplest solution is to reset the grid, as shown in the example below.

Initial Load Error

Clicking the "Retry - it will work now" button calls the reset method on the server data source, which resends the initial data request to the server.

Handle Slice Failures

Even after the initial request succeeds, subsequent requests can still fail. The LyteNyte Grid server data source provides the retry method to reattempt failed data requests. This method clears the error state and resends only the failed requests that are currently in view; failed requests outside the view are skipped but still have their error state cleared.

In the example below, scroll down a few rows to trigger some failed requests. Clicking the "Retry Failed" button clears the error state and re-requests the affected rows. The subsequent requests will succeed.

Failed Row Slice

Handling Group Failures

The retry method also handles failed group expansions. Call it to retry a group expansion that failed, and all associated errored requests will be retried. In the example below, expanding a group triggers a failure. Clicking the exclamation icon retries the failed requests, and the subsequent requests succeed.

Group Expansion Failure

The retry method is invoked in the GroupCellRenderer button component:

<button
onClick={() => {
(grid.state.rowDataSource.get() as RowDataSourceServer<SalaryData>).retry();
}}
>
<ExclamationTriangleIcon />
</button>

The TypeScript cast is required because the server data source is a subtype of the general row data source.

Next Steps