Ability to customize individual cell rendering within tables - like widgets but at the table cell level
jimmybutton opened this issue ยท 6 comments
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
Not sure how difficult that would be though.
But... you example here should have worked too! https://django-sql-dashboard.datasette.io/en/stable/widgets.html#html
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
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
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
Maybe a similar mechanism would be useful for Django SQL Dashboard as well.
Hey @simonw, thanks for your replies and explanations. An ability to control widgets for individual cells sounds pretty amazing. Love the mp3 player example!