Is it possible to get the index of the last visible row while scrolling?

Hello.

I would like to get the index of the last visible row while scrolling the grid. How do achieve this result?


3 Replies 1 reply marked as answer

DM Dhanasekar Mohanraj Syncfusion Team May 9, 2022 01:56 PM UTC

Hi ZipGenius Team,

You can achieve your requirement by using below code,

C#:

int lastVisibleLineIndex = this.dataGrid.AutoScroller.VisualContainer.ScrollRows.LastBodyVisibleLineIndex;


Please check this and revert us if you need further assistance for this.

Regards,
Dhanasekar M.


Marked as answer

TZ The ZipGenius Team replied to Dhanasekar Mohanraj May 12, 2022 05:23 PM UTC

Thank you very much.

I used that line of code in "sfDataGrid.AutoScroller.VisualContainer.PointerWheelChanged" event which fires only when scrolling the DataGrid with the mouse wheel but not if I use the vertical scrollbar by dragging it. Is there any other event for this? I cannot find any suitable.



DM Dhanasekar Mohanraj Syncfusion Team May 13, 2022 02:24 PM UTC

Hi ZipGenius Team,

You can get the notifications while scrolling the SfDatagrid by using below mentioned events,

  1. this.dataGrid.AutoScroller.VisualContainer.ScrollOwner.ViewChanging,

  2. this.dataGrid.AutoScroller.VisualContainer.ScrollOwner.ViewChanged,

  3. this.dataGrid.AutoScroller.VisualContainer.EffectiveViewportChanged

Could you please check these events and choose which is meet your requirement exactly. Please revert us if you need further assistance for this.

Regards,
Dhanasekar M.


Loader.
Up arrow icon