h2oai / wave

Realtime Web Apps and Dashboards for Python and R
https://wave.h2o.ai
Apache License 2.0
3.9k stars 324 forks source link

First column set to markdown, will not be hyperlinked #2086

Closed Sivakajan-tech closed 11 months ago

Sivakajan-tech commented 11 months ago

Wave SDK Version, OS

Wave SDK: 0.24.2 , OS: MacOs

Actual behaviour

When the cell_type=ui.markdown_table_cell_type() argument is added to the first ui.table_column(), the column element itself will not be a hyperlink. I used the hyperlink to open the side-panel. cell_type=ui.markdown_table_cell_type() argument can be use for many cases, I used this to apply the <pre> tag to the element.

Expected behavior

When the cell_type=ui.markdown_table_cell_type() argument is added to the first ui.table_column(), the column element should be a hyperlink and should be raised the args element. (for @on() handler)

Steps To Reproduce

from h2o_wave import main, app, Q, ui

@app('/demo')
async def serve(q: Q):
    if not q.args.table:
        q.page['meta'] = ui.meta_card(box='')
        q.page['example'] = ui.form_card(box='1 1 3 3', items=[
            ui.table(
                name='table',
                columns=[
                    ui.table_column(name='name', label='Name',cell_type=ui.markdown_table_cell_type()),
                    ui.table_column(name='surname', label='Surname'),
                ],
                rows=[
                    ui.table_row(name='row1', cells=['John', 'Doe']),
                    ui.table_row(name='row2', cells=['Alice', 'Smith']),
                    ui.table_row(name='row3', cells=['Bob', 'Adams']),
                ]
            )
        ])
    else:
        q.page["meta"].side_panel = ui.side_panel(
            name="overview_panel",
            title="Overview",
            width="650px",
            items=[],
            events=["dismissed"],
            closable=True,
            blocking=True,
        )

    await q.page.save()

https://github.com/h2oai/wave/assets/51718908/253492d6-c41c-4da0-825c-6cf3de2dc707

cc: @ShehanIshanka

mturoci commented 11 months ago

This is expected. Wave cannot know if you wish to use default links along with markdown cell type or not. However if you want to use both markdown and the default link behavior, you can go for something like this:

from h2o_wave import main, app, Q, ui

@app('/demo')
async def serve(q: Q):
    if not q.args.table:
        q.page['meta'] = ui.meta_card(box='')
        q.page['example'] = ui.form_card(box='1 1 3 3', items=[
            ui.table(
                name='table',
                columns=[
                    ui.table_column(name='name', label='Name',cell_type=ui.markdown_table_cell_type()),
                    ui.table_column(name='surname', label='Surname'),
                ],
                rows=[
                    ui.table_row(name='row1', cells=['[John](?table)', 'Doe']),
                    ui.table_row(name='row2', cells=['[Alice](?table)', 'Smith']),
                    ui.table_row(name='row3', cells=['[Bob](?table)', 'Adams']),
                ]
            )
        ])
    else:
        q.page["meta"].side_panel = ui.side_panel(
            name="overview_panel",
            title="Overview",
            width="650px",
            items=[],
            events=["dismissed"],
            closable=True,
            blocking=True,
        )

    await q.page.save()