FastUI
FastUI copied to clipboard
Is there some way to put components in table?
I'm tring to add some links by markdown on table's row, for operating my data, but seems markdown won't be rendered in table component.
Is there another way to add at least two link to a table cell?
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from fastui import FastUI, prebuilt_html
from fastui import components as c
from fastui.components.display import DisplayLookup, DisplayMode
from pydantic import BaseModel
app = FastAPI()
class Fake(BaseModel):
name: str
action: str
@app.get("/api/", response_model=FastUI, response_model_exclude_none=True)
async def ui():
fake = [Fake(name="demo", action="[rename](/rename) [remove](/remove)")]
return [
c.Page(
components=[
c.Table(
data=fake,
columns=[
DisplayLookup(field="name"),
DisplayLookup(field="action", mode=DisplayMode.markdown),
],
),
]
)
]
@app.get("/{path:path}")
def index(path: str) -> HTMLResponse:
print(path)
return HTMLResponse(prebuilt_html())
@Dragon-GCS,
Thanks for the feature request. Definitely something we will consider for future releases!
It would also be great to be able to embed a button into the cell. E.g., you could add an "edit" button to open a form modal.
I think this would be really helpful.
Fixed by https://github.com/pydantic/FastUI/pull/279
Also, you might want to check out https://github.com/pydantic/FastUI/pull/308