Scroll to newly inserted (selected) row (programmatic row focus)
See original GitHub issueI’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:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
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
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.