This is a migrated thread and some comments may be shown as answers.

[Solved] Grid auto scroll to last record

5 Answers 375 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sanjay
Top achievements
Rank 1
Sanjay asked on 26 Mar 2015, 06:00 AM
Hi,

I have a read-only grid where I am using .READ method to fetch data from the database and show it on screen. The grid has a scrollbar. I want the grid to auto scroll to the end so that the last record is visible on screen.

Please help.

Regards,
Sanjay

5 Answers, 1 is accepted

Sort by
0
Accepted
Matt Barker
Top achievements
Rank 1
answered on 26 Mar 2015, 02:05 PM
Something like this?
var grids = document.getElementsByClassName('k-grid-content'),
    index = 0,
    grid;
 
for (; index < grids.length; index++) {
    grid = grids[index];
    grid.scrollTop = grid.scrollHeight;
}
0
Sanjay
Top achievements
Rank 1
answered on 27 Mar 2015, 03:42 AM
Something strange is happening. The value for grid.scrollTop remain 0 even though grid.scrollHeight is not 0.





0
Matt Barker
Top achievements
Rank 1
answered on 27 Mar 2015, 09:58 AM
Then I think that you must have a code error somewhere. It works for me on the latest version of Chrome on Windows XP:
https://jsfiddle.net/56omxkv1/
0
Accepted
Vladimir Iliev
Telerik team
answered on 30 Mar 2015, 07:01 AM
Hello Sanjay,

The Matthew's approach is valid and works as expected on our side as well. Here you can find another similar example of scrolling the grid content to given row. 

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sanjay
Top achievements
Rank 1
answered on 30 Mar 2015, 09:28 AM
Dear Vladimir/Matt,

Sorry it was error in my code. Both the approach works.

Thanks

Regards,
Sanjay
Tags
Grid
Asked by
Sanjay
Top achievements
Rank 1
Answers by
Matt Barker
Top achievements
Rank 1
Sanjay
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or