Skip to content

How to (auto)-set the column widths? #399

@ShixiangWang

Description

@ShixiangWang

Dear @glin ,

I am currently facing challenges in setting appropriate widths for my multi-column tables. Despite numerous adjustments, I am not yet satisfied with the outcomes. My goal is to ensure that all column headers are clearly visible and that the widths are optimally suited for the content in each column. I have attempted to set a fixed table width and have sought advice from discussions on Stack Overflow, but the solutions have not been effective for my specific dataset.

image
columns = list(
          id = colDef(name = "Cohort ID", sticky = "left"),
          name = colDef(
            name = "Cohort Name",
            sticky = "left",
            # Add a right border style to visually distinguish the sticky column
            style = list(borderRight = "1px solid #eee"),
            headerStyle = list(borderRight = "1px solid #eee")
          ),
          cancer_type = colDef(name = "Cancer Type", minWidth = 50),
          treatment = colDef(name = "Treatment"),
          drug = colDef(name = "Drug"),
          time = colDef(name = "Sampling Time", minWidth = 60),
          N = colDef(name = "N", minWidth = 30),
          year = colDef(name = "Year", minWidth = 40),
          Label = colDef(name = "Label", minWidth = 30),
          Surv = colDef(name = "Surv Info", minWidth = 60),
          doi = colDef(name = "DOI", html = TRUE, cell = htmlwidgets::JS('
            function(cellInfo) {
              // Render as paper link
              const url = `https://doi.org/${cellInfo.value}`
              return `<a href="${url}" target="_blank">${cellInfo.value}</a>`
            }
          '))
        )

Best,

Shixiang

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions