posit-dev / great-tables

Make awesome display tables using Python.
https://posit-dev.github.io/great-tables/
MIT License
1.42k stars 48 forks source link

Support interactivity for HTML output #370

Open kszlim opened 1 month ago

kszlim commented 1 month ago

Prework

Proposal

Support interactivity for html output of great tables. This might be a big ask, I don't know how technically involved it would be, but it would be great to allow basic interactivity like sorting by column, filtering.

I think you'd then want to support a new param in as_raw_html with interactive=True which would then enable these features. Or perhaps it could be a bunch of method calls on table to enable piecemeal interactivity.

This would be a killer feature personally.

Some inspiration could be the level of interactivity of https://docs.datapane.com/blocks/display-blocks/#tables-and-data

ctdunc commented 1 month ago

I have also been meditating on the fact that this would be an incredible feature. Assuming this is running on a webserver, the interactivity would be at least somewhat tied to the framework that a user chooses (e.g. Flask or Django).

One interesting possibility I've daydreamed about is to provide htmx attributes to different table components that correspond to actions to be performed on the dataframe. This way, great-tables has to incorporate very little (if any) JS and can instead rerender the parts of the table updated by the change using the already existing layout framework.

I would be interested in helping to make this a reality :)

kszlim commented 1 month ago

I think this should theoretically be doable without a webserver, in fact, I think I wouldn't want this feature if it required a webserver.

It should be all doable clientside. Even supporting SQL theoretically can be done clientside (though I think some minimal interactivity is usually all that's needed).

machow commented 3 weeks ago

Thanks for opening this--we're definitely eager to support something like this! Right now, we're syncing with the shiny team (cc @schloerke) on potentially...

  1. enabling the range of great tables structure and styling on their Data Grid component.
  2. eventually trying to pull out the DataGrid into it's own library, so Great Tables could generate these tables without the need for a web server backend.

AFAIK they're using the tanstack table.

Building on the tanstack table

The R version of Great Tables (gt) uses a wrapper around the tanstack table, called reactable, to generate interactive tables. If we could create a similar wrapper in python, it shouldn't be too hard to wire up Great Tables to it.

Here are some examples of the gt packages interactive tables.

Building on something else

If anyone knows of something better, we're open to it! I know there are a lot of interactive table tools out there that we've probably overlooked!

Potential requirements

  1. Doesn't require a webserver (but could have hooks to optionally wire one up; e.g. shiny, django, fastapi)
  2. Easy to use from things like jupyter lab and VS Code
  3. Clear table building interface Great Tables plugs into
jrycw commented 3 weeks ago

I've seen an example from Panel a few months ago that might be a potential solution for our use case.

machow commented 3 weeks ago

Oh cool! Here's the panel Tabulator page, which seems to be similar to reactable