【发布时间】:2018-04-04 11:57:20
【问题描述】:
我有一个闪亮的应用程序,我在其中使用 DT 库来可视化表格。我正在使用容器来呈现表格。
sketch = htmltools::withTags(table(
class = 'display',
thead(
tr(
th(rowspan = 2, 'Name'),
th(rowspan = 2, 'Description'),
th(rowspan = 2, 'From'),
th(rowspan = 2, 'To'),
th(rowspan = 2, 'Duration'),
th(colspan = 3, 'Rain', style="text-align:center"),
th(colspan = 3, 'Flow', style="text-align:center"),
th(colspan = 3, 'Depth', style="text-align:center"),
th(colspan = 3, 'Velocity', style="text-align:center")
),
tr(
lapply(rep(c('Min', 'Max', 'Mean'), 4), th)
)
)))
output$table2 <- DT::renderDataTable({
datatable(eventSelection[[input$options]], class = 'cell-border stripe table-hover', rownames = FALSE, container = sketch,
extensions = 'Buttons', options = list(scrollX = TRUE, dom = 'Bfrtip', buttons = I('colvis'))
) %>%
formatDate(c(3,4), method='toLocaleString') %>%
formatRound(5:17, digits = 3)
})
表格如下所示:
我希望在列可见性选项卡中拥有 Rain、Flow、Depth、Velocity 选项,并且能够在我单击它们时隐藏相应的 Min、Max 和 Mean 统计列。最好的方法是什么?
谢谢!
【问题讨论】:
标签: javascript r datatables shiny dt