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

select row and scroll to it?

3 Answers 16 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Veteran
Ed asked on 06 Feb 2020, 08:50 AM

 

Is there a way to do this in code?

Thanks … Ed

 

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 10 Feb 2020, 04:20 PM

Hello Ed,

Assuming you have configured the Grid to be selectable, scrollable and its height, e.g.:

.Selectable(selectable => selectable.Enabled(true))
.Scrollable()
.HtmlAttributes(new { style = "height: 500px" })

you can select a row and scroll to it as demonstrated below:

<input type="button" value="Row 10 select and scroll" onclick="selectAndScroll()" />

<script>	
  function selectAndScroll() {
    var grid = $("#grid").data("kendoGrid");
    grid.select("tr:eq(10)");
    var scrollContentOffset = grid.element.find("tbody").offset().top;
    var selectContentOffset = grid.select().offset().top;
    var distance = selectContentOffset - scrollContentOffset;

    grid.element.find(".k-grid-content").animate({
      scrollTop: distance
    }, 400);
  }
</script>

This selects and scrolls to the 10th row. The highlighted part should be replaced with the actual Grid name.

Regards,
Ivan Danchev
Progress Telerik

Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
0
Ed
Top achievements
Rank 1
Veteran
answered on 11 Feb 2020, 11:22 AM

Hi,

Thanks. Will that work with a row that is on another grid page?

Thanks … Ed

 

0
Ivan Danchev
Telerik team
answered on 14 Feb 2020, 08:57 AM

Ed,

This will not work for other pages because the rows of the pages other than the currently selected one are not rendered. For performance reasons, the Grid renders only the rows of the selected page.

Regards,
Ivan Danchev
Progress Telerik

Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
Tags
Grid
Asked by
Ed
Top achievements
Rank 1
Veteran
Answers by
Ivan Danchev
Telerik team
Ed
Top achievements
Rank 1
Veteran
Share this question
or