Highlighting a selected grid row that uses OData Server Operations

1 Answer 62 Views
Grid
SoH
Top achievements
Rank 1
Iron
Veteran
Iron
SoH asked on 27 Sep 2023, 03:52 PM

I have implemented a grid using OData Server Operations, very similar to this example:
https://www.telerik.com/kendo-react-ui/components/grid/data-operations/odata-server-operations/

But now I can't highlight the selected row. Using the process function does not allow for server side paging, filtering or sorting.

I can't use `getSelectedState` as my version of the grid has no exported member.

Is there any other way I can highlight the selected row?

1 Answer, 1 is accepted

Sort by
0
SoH
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 28 Sep 2023, 09:28 AM

I slept on this problem and realised there was an easy fix.

Before setting the local state with the grid data,  I set the selected row in the data inside a useEffect().

useEffect(() => {
    const localData = {...props.gridData};
    const updatedData = localData.data.map((item) => ({ ...item, selected: item.id === selectedId }))
    setData({data: updatedData, total: localData.total})
  }, [props.gridData, selectedId]);

 

Filip
Telerik team
commented on 29 Sep 2023, 11:54 AM

Hi, sc cs,

Yes, setting the selected row in the data inside a useEffect should fix it.

Let us know if further assistance is required.

Regards,

Filip

Tags
Grid
Asked by
SoH
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
SoH
Top achievements
Rank 1
Iron
Veteran
Iron
Share this question
or