Premium
The RSC architecture introduces server actions
, which are seamlessly integrated in the server mode of the KendoReact Grid.
Server-actions compatibility allows passing functions to the component's callbacks, such as onDataStateChange
or onItemChange
, enabling the execution of custom server-side logic.
In the server mode of the Grid, the events fall into two categories:
onFilterChange
onSortChange
onPageChange
onGroupChange
onDataStateChange
—triggered when either one of the onFilterChange
, onSortChange
, onPageChange
or onGroupChange
events occurs.To use event handlers on a server page, you can use the same setup as you would for a Grid on a client page. The key differences are:
async
and include 'use server'
at the top.ServerEvent<T>
type to ensure compatibility.Client event arguments such as
nativeEvent
,syntheticEvent
,target
,targetEvent
, andfocusElement
cannot be serialized to the server and will always beundefined
.
Here is an example of a server action managing the Grid’s data state:
const onDataStateChange = async (event: ServerEvent<GridDataStateChangeEvent>) => {
'use server';
cookies().set(TAG, JSON.stringify(event.dataState));
};
return <Grid onDataStateChange={onDataStateChange} dataItemKey={dataItemKey}></Grid>;
Limitations Client-only Events
There are some current events of the Grid that only make sense in a client scenario. As a result, the following events will not be triggered when the Grid is used as a server component:
Suggested LinksRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4