且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

闪亮:无法在闪亮数据表中设置列宽

更新时间:2023-12-01 18:43:58

您需要根据 scrollX = TRUE 问题/ 29rel =nofollow> https://github.com/rstudio/DT/issues/29


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.

Thanks!

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