rshinydt

Shiny: Unable to set column width in Shiny DataTables


I'm pretty new to Shiny and DataTables, so this might be a silly question. I cannot change the column width for some reason. I tried

 output$table<-DT::renderDataTable(
  {withProgress(message="Compiling",
                {dataInput()}
               )
  },
  filter="top",
  rownames=FALSE,
  options=list(lengthMenu=c(5,10,25,50,100),
               pageLength=25,
               searchHighlight=TRUE,
               autoWidth=TRUE,
               columnDefs=list(list(width="200px",targets="_all"))
              )
)

but it doesn't work (I can tell because the columns have different widths). I also tried using the old aoColumnDefs and bAutoWidth, and setting autoWidth=FALSE, but neither works.

My DT has 33 columns, so maybe it's because there's a total width limit when displaying DTs in Shiny? Anyway, it would be extremely helpful if anyone can help me solve this problem.


Solution

  • You need to add scrollX=TRUE in the options as per https://github.com/rstudio/DT/issues/29