This is a migrated thread and some comments may be shown as answers.
RadGridView scroll postion works with real numbers only
2 Answers 9 Views
This is a migrated thread and some comments may be shown as answers.
Andrey
Top achievements
Rank 1
Andrey asked on 07 Jan 2021, 04:43 PM

Greetings,

 

         I am interested in knowing why code 1 works but code 2 below does not in repositioning the scroll on a RadGridView. Also, any posibile solution as to why code 2 does not work would be appreciated. Thank you.

Works:

Code 1 : dvTrackingLog.TableElement.ScrollTo(30, 0);

Code 1a: dvTrackingLog.CurrentRow = dvTrackingLog.Rows[30];

AutoScrollGrid(30);

Code 1b: dvTrackingLog.TableElement.ScrollTo(rowIndex, 0);

Code 1c: dvTrackingLog.CurrentRow = dvTrackingLog.Rows[rowIndex];

Does not work:

Code 2: dvTrackingLog.TableElement.ScrollTo(dvTrackingLog.SelectedRows[0].Index, 0);

Code 2a: dvTrackingLog.CurrentRow = dvTrackingLog.Rows[dvTrackingLog.SelectedRows[0].Index];

AutoScrollGrid(rowIndex);

Code 2b: dvTrackingLog.TableElement.ScrollTo(rowIndex, 0);

Code 2c: dvTrackingLog.CurrentRow = dvTrackingLog.Rows[rowIndex];

 

 

2 Answers, 1 is accepted

Sort by
0
Nadya
Telerik team
answered on 11 Jan 2021, 01:05 PM

Hello, Andrey,

SelectedRows collection gets the collection of selected rows by the user. SelectedRows[0] will give you the first selected row. By default, when the grid is initially loaded the first selected row is the first row with Index = 0. According to the provided code snippet, it is not clear when you call the ScrollTo method in your project but if the grid does not scroll it seems that the SelectedRows[0].Index is 0 which means that the first row is selected.

For example, let's change the selected row to be the fifth row:

this.radGridView1.Rows[5].IsSelected = true;
this.radGridView1.TableElement.ScrollTo(radGridView1.SelectedRows[0].Index, 0);

You can see in the attached gif file that the grid scrolls correctly to the fifth row.

I attached my sample project for your reference. Can you give it a try and see how it works.

I hope this helps. If you have further questions please let me know.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Andrey
Top achievements
Rank 1
answered on 12 Jan 2021, 07:52 PM
Thank you for your input. Issue has been resolved. 
Asked by
Andrey
Top achievements
Rank 1
Answers by
Nadya
Telerik team
Andrey
Top achievements
Rank 1
Share this question
or