FastUI icon indicating copy to clipboard operation
FastUI copied to clipboard

Is there some way to put components in table?

Open Dragon-GCS opened this issue 11 months ago • 2 comments

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())

image

Dragon-GCS avatar Mar 15 '24 12:03 Dragon-GCS

@Dragon-GCS,

Thanks for the feature request. Definitely something we will consider for future releases!

sydney-runkle avatar May 02 '24 00:05 sydney-runkle

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.

MMartin09 avatar May 12 '24 16:05 MMartin09

Fixed by https://github.com/pydantic/FastUI/pull/279

Also, you might want to check out https://github.com/pydantic/FastUI/pull/308

sydney-runkle avatar May 30 '24 14:05 sydney-runkle