How to Scroll Into View and Highlight Row in Grid

1 Answer 17 Views
Grid
Layla
Top achievements
Rank 1
Layla asked on 05 May 2025, 07:58 PM | edited on 07 May 2025, 03:46 PM

Hey Team!

We're looking to implement a scroll into view for our Kendo grid using Typescript. This example is similar to what we are looking to do when the grid first loads. https://www.telerik.com/kendo-react-ui/components/grid/scroll-modes/scroll-into-view 

Is it possible to change the background color of the row once it scrolls to the target row?

Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 07 May 2025, 03:47 PM

Hi, Layla,

The functionality demonstrated in the linked demo of the Grid is achieved with the `scrollIntoView` method which aims to scroll to the n-th child of an HTML container and cannot work with the dataItems bound to the Grid Row objects. If you implement a logic finding the index of the row containing the target data, though, you can execute the `scrollIntoView` logic from the linked demo once the Grid is loaded through the useEffect hook like follows:

  const [targetRowIndex, setTargetRowIndex] = React.useState(20);

  React.useEffect(() => {
    if (gridRef.current) {
      gridRef.current.scrollIntoView({ rowIndex: targetRowIndex });
    }
  });

I hope this helps.

Kind regards,
Vessy
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Layla
Top achievements
Rank 1
commented on 07 May 2025, 10:06 PM

Hi Vessy,

Thank you for your response. When I try to import GridHandle, I get an error:

Module '"@progress/kendo-react-grid"' has no exported member 'GridHandle'.ts(2305)

It looks like we are using "@progress/kendo-react-grid": "^5.16.1". Is the scroll into view functionality still possible with this older version? 

 

Vessy
Telerik team
commented on 09 May 2025, 01:34 PM

Hi, Layla,

Yes, you should be able to use the scroll into view functionality in the used by you version as well. You can try removing the GridHandle import and replacing its usage with <any> (in case you are using Typescript):
https://stackblitz.com/edit/react-tpwhyp4w-dzpzevcz?file=package.json,app%2Fapp.tsx 

Tags
Grid
Asked by
Layla
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or