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

Ability to customize individual cell rendering within tables - like widgets but at the table cell level #154

Open
jimmybutton opened this issue Sep 2, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@jimmybutton
Copy link

Not sure if this pushes things a bit too far, but I thought it would be nice to be able to have a table on one dashboard, where each row displays a link that would take the user to a different dashboard that displays details about that row (e.g. by passing the id as a parameter for the other dashboard). This could be done e.g. by allowing to render individual cells as markdown or html. Essentially s.th. like this
screenshot
Not sure how difficult that would be though.

@simonw
Copy link
Owner

simonw commented Sep 2, 2022

You can do this today by returning the raw URL - there's code that spots URLs and turns them into clickable links:

image

@simonw
Copy link
Owner

simonw commented Sep 2, 2022

But... you example here should have worked too! https://django-sql-dashboard.datasette.io/en/stable/widgets.html#html

@simonw
Copy link
Owner

simonw commented Sep 2, 2022

Oh I see what happened here: the as html thing only works if that's the ONLY column you return from your query at the moment.

So your example would work if you did something like this instead:

select '<a href="/dashboards/details?id=' || id || 
  '">click here</a><p>' || created_at || '</p><p>' || logs
as html 
from myapp table

@simonw
Copy link
Owner

simonw commented Sep 2, 2022

So really the feature you are suggesting here is to make it so you can return a table but have custom treatment of the individual table cells - as opposed to the current mechanism where widgets replace the table entirely with an alternative display: https://django-sql-dashboard.datasette.io/en/stable/widgets.html

@simonw
Copy link
Owner

simonw commented Sep 2, 2022

I've done a lot of work with this kind of thing in Datasette - there's a render_cell() plugin hook which plugins can use to customize individual cell display, for example the MP3 player widgets on this page: https://scotrail.datasette.io/scotrail/assemble_sentence?terms=i+am+sorry%2C+scotrail%2C+from%2C+bath+spa%2C+is+delayed%2C+due+to%2C+bomb

image

Maybe a similar mechanism would be useful for Django SQL Dashboard as well.

@simonw simonw changed the title Figure out a way to display a link in a table cell (e.g. to link to another dashboard) Ability to customize individual cell rendering within tables - like widgets but at the table cell level Sep 2, 2022
@simonw simonw added the enhancement New feature or request label Sep 2, 2022
@jimmybutton
Copy link
Author

Hey @simonw, thanks for your replies and explanations. An ability to control widgets for individual cells sounds pretty amazing. Love the mp3 player example!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants