question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scroll to newly inserted (selected) row (programmatic row focus)

See original GitHub issue

I’m submitting a … (check one with “x”)

[ ] bug report => search github for a similar issue or PR before submitting
[x ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior While there doesn’t appear to be api’s to insert a specific row, its easily accomplished by inserting rows into the dataset. What I’d ultimately like to be able to do is scroll to newly inserted rows… (and that could be as simple as just creating the row data, inserting, setting that as the selected item. (so no need to build functionality to specifically scroll to an inserted or selected record).

Expected behavior What I’d liked to be able to do is provide it a row, or index or something, and be able to scroll to that item. When the row item is displayed (virtual scrolling), I could technically get a reference to datatable-body-row.datatable-body-row.active, but naturally that dissapears as soon as that row is scrolled out of view.

What is the motivation / use case for changing the behavior? Current API lets you programatically select a row, but if that row happens to scrolled off the screen whilst selected element is set, its not clear there is a selection

Please tell us about your environment:

  • Table version: 0.8.x Currently 9.0.0

  • Angular version: 2.0.x 4.0.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] all browsers should be affected as this appears to be new functionality

  • Language: [all | TypeScript X.X | ES6/7 | ES5] typescript 2.3.2

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
szpetnycommented, Oct 4, 2017

So it looks like it is possible to do it like this: tableEl.bodyComponent.updateOffsetY(row.index/tableEl.bodyComponent.pageSize)

I’m using it with constant rowHeight and [scrollbarV]=“true”. If the rowHeight is not a const it doesn’t work. And when there’s no scrollbarV set, apparently there is no need to divide by pageSize see: https://github.com/swimlane/ngx-datatable/blob/570474875e9c57657ea94512ed283078d04e95dc/src/components/body/body.component.ts#L294 xD

Btw found it here (thx): https://github.com/swimlane/ngx-datatable/issues/440

2reactions
amcdnlcommented, Aug 4, 2017

A external API to jump to a row index might be the desired result here. Shouldn’t be too hard to implement if you wanna PR that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dxDataGrid - How to scroll to the selected row programmatically
I want to programmatically select a row using selection api and also with more records(aroudn 200), I want to select 190th record and...
Read more >
How to scroll to newly added row in a table automatically ...
I am performing CURD operations on Table. In a table at a time only six rows are visible.If we want to see more...
Read more >
Programatically Re-Select the Row and Scroll Automatically
Hi All,. I have a win grid with a max of 5000 rows at any given point of time. So the user will...
Read more >
How to programmatically select and focus a row or cell in a ...
For example, the row doesn't get highlighted the same way and if you try to use the arrow keys of the keyboard to...
Read more >
Force Scrolling to Selected Element - Kendo UI Grid for jQuery
An example on how to scroll to the selected row in the Kendo UI Grid. ... New to Kendo UI for jQuery? ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found