Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ShixiangWang opened this issue Dec 20, 2024 · 0 comments
Open

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

ShixiangWang opened this issue Dec 20, 2024 · 0 comments

Comments

@ShixiangWang
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant