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

grid.scrollTo ( $row )

2 Answers 848 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim R
Top achievements
Rank 1
Tim R asked on 21 Feb 2013, 01:25 PM
          kendoGrid.scrollTo( $row );

What is the most reliable way, in the opinion of the kendo staff?

This would be a good built-in method to add to the API.


EDIT: Got it!

        var _offset = $(myRow).offset();
        var _topoffset = _offset.top;
        $("#grid div.k-grid-content").scrollTop(_topoffset);





        






           

2 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 07 May 2014, 08:55 PM
I've discovered that if the grid isn't on top then things go bad.  Everything I've seen says to use offset but I switched to position and it works for grids that are down lower on the page

If anyone's having issues with offset being 'off' try this (dataBound event) code which scolls a row into view and selects it:

var grid = this;
var row = grid.table.find('div[data-isselected="true"]').closest("tr");  // custom data attribute I put on one of the columns
if (row.length != 0) {
    $("#gridProjects div.k-grid-content").scrollTop($(row).position().top); //scroll the content
}
grid.select(row);
0
Curt Rabon
Top achievements
Rank 1
Veteran
answered on 20 Mar 2015, 04:37 PM
If you have a reference to the grid object, then 1 small thing I discovered (using Firefox web console), is that in addition to using gridObject.tbody, you can also use gridObject.content  ...which is the <div class="k-grid-content".

So, you can do: myGridObj.content.scrollTop()
Tags
Grid
Asked by
Tim R
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Curt Rabon
Top achievements
Rank 1
Veteran
Share this question
or