Skip to content

specify different column widths in render.DataGrid() #1324

@mdaeron

Description

@mdaeron

Is there a canonical way to specify different column widths in render.DataGrid()?

In the following example, I'd like to keep columns a and b at a reasonably small width, while allowing column c to expand enough to accommodate long lines of text.

from shiny import App, Inputs, Outputs, Session, render, ui
import pandas as pd

df = pd.DataFrame(
  {
    "a": [0],
    "b": [0.1],
    "c": ["A very long line that goes on and on and on"],
  }
)

app_ui = ui.page_fluid(
  ui.card(
    ui.output_data_frame("odf"),
  ),
)

def server(input: Inputs, output: Outputs, session: Session):

  @render.data_frame
  def odf():
    return render.DataGrid(df)

app = App(app_ui, server)
Screen Shot 2024-04-19 at 16 04 41

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions