Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Tabulator scrollToRow #2485

Closed
douglas-raillard-arm opened this issue Jul 2, 2021 · 3 comments · Fixed by #2503
Closed

Support Tabulator scrollToRow #2485

douglas-raillard-arm opened this issue Jul 2, 2021 · 3 comments · Fixed by #2503
Labels
type: enhancement Minor feature or improvement to an existing feature

Comments

@douglas-raillard-arm
Copy link
Contributor

douglas-raillard-arm commented Jul 2, 2021

Is your feature request related to a problem? Please describe.

Being able to scroll inside the table programmatically is very useful when linking plots with custom interactivity with some tabular data.

Describe the solution you'd like

An API allowing to scroll to the given row, and possibly linked to a stream so that a holoviews plot X position can scroll directly in a table displayed under it.

Tabulator seems to already have support for scrolling programmatically:
http://tabulator.info/docs/4.1/navigation#scroll-row

Describe alternatives you've considered

pn.widgets.DataFrame() automatically scrolls when its "selection" attribute is modified. It would be nice to have a similar behavior for Tabulator.

EDIT: add alternative

@philippjfr philippjfr added the type: enhancement Minor feature or improvement to an existing feature label Jul 5, 2021
@philippjfr
Copy link
Member

I'm out on vacation this week but will work a little bit on Thursday to release Panel 0.12. If a PR to implement this were to magically appear before then I'd happily merge it and get it into this release :)

@douglas-raillard-arm
Copy link
Contributor Author

First time I touch Javascript in ~14 years but I'll give that a shot, I guess it should not be too hard :)

@douglas-raillard-arm
Copy link
Contributor Author

So as a starter I was contemplating scrolling to the currently selected row, like pn.widgets.DataFrame. I tried this:

import panel as pn
pn.extension('tabulator')
import pandas as pd

df = pd.DataFrame(dict(a=[1,2], b=[3,4]))
df = pd.concat([df]*10)
df = df.reset_index(drop=True)

table = pn.widgets.Tabulator(df, height=100)
table

# Experiment with jscallback to see how it works
value1 =   pn.widgets.Spinner(value=0, width=75)
result =   pn.widgets.StaticText(value='0', width=50, align='center')

value1.jscallback(value="""
  result.text = v1.value.toString()
""", args={'result': result, 'v1': value1, 'thetb': table})

pn.Row(value1, result)

In the little experiment with jscallback, everything works well, until I add 'thetb': table to the args dict. I tried some console.log() to no avail. It looks like that binding the Tabulator widget to a callback like that breaks the callback, which never fires.

Any idea on what is happening ?

douglas-raillard-arm pushed a commit to douglas-raillard-arm/panel that referenced this issue Jul 7, 2021
Scroll automatically to the selected rows when the selection is updated,
just like the DataFrame widget.

Closes holoviz#2485
philippjfr pushed a commit that referenced this issue Jul 15, 2021
Scroll automatically to the selected rows when the selection is updated,
just like the DataFrame widget.

Closes #2485

Co-authored-by: Douglas RAILLARD <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants