且构网

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

R闪亮设置DataTable列宽

更新时间:2022-12-21 21:14:11

尝试一下

#OUTPUT - dtdata
output$table <- DT::renderDataTable({
  data.frame(a=c(1,2,3,4,5),b=c("A","B","C","D","E"))
},
options = list(
  autoWidth = TRUE,
  columnDefs = list(list(width = '200px', targets = "_all"))
))

将所有列的宽度设置为200px。

Sets the width of all columns to 200px.

要设置选定列的宽度,请将目标更改为数字或向量。

To set width of selected columns, change targetsto a number or vector.

targets = c(1,3)