Move scroll bar in perspective table to the location of selected row

Hello everyone,

When I change the “SelectedRow” in the perspective table component, the scroll bar does not move to the selected row location. Below is the video. Any idea how this can be fixed? Thank you!

This isn't something you can directly do currently, though it's a feature on our backlog:

1 Like

Thank you, Paul!

If I want to do this indirectly, what would be the best method to do it? Should I use the Property change script on “SelectedRow”?
Not sure how to command the scroll bar to move to the selected row location. Do we even have any command for the scroll bar itself? I know there is one for vision but could not find any for perspective.

Nope, that’s exactly what I requested for. They need to expose the JavaScript function to scroll to position. It’s not possible to do now and there is no workaround like you can in Vision where you could manipulate the backend Java objects

1 Like

Thank you very much, Nick. Appreciate the information.

Has there been any progress on this issue? I need this incorporated into my project.

No change on our internal ticket in the backlog since my last post.

You can use the Markdown component to inject JS to do this for the time being. Perspective table cell question - #3 by victordcq

Note: the table should be set to non-virtualised for this to work properly

You will soon be able to do this using Periscope:

args = {
	'componentPath': 'root/Table', # path to the table component
	'rowIndex': 10                 # the row to scroll to
}

system.perspective.runJavaScriptAsync('''(rowIndex, componentPath) => {	
	const { view } = perspective.context

	const table = view.findDescendantByNames(view, componentPath.split('/'))
  	const row = table.element.querySelector(`[data-row-index="${rowIndex}"]`)

	row?.scrollIntoView({ block: 'center', behavior: 'smooth' })
}''', args)

This doesn't work in 0.11.0 because the perspective.context of a runJavaScript call doesn't actually contain a view reference... :man_shrugging: Everything is hooked up to provide the reference, but the last little bit of code is missing lol.

Also there may be a smarter way to specify the path to the table component, but this is the fastest thing I could come up with.