【发布时间】:2018-11-24 11:35:12
【问题描述】:
我的目标是显示一些数据表和:
1) 为所有表启用列重新排序
2) 启用更改表顺序。
我的第一次尝试是将shinyjqui::jqui_sortable 与DT::datatable 结合使用。
对于列重新排序,ColReorder 扩展名做得很好,例如
library(DT)
datatable(mtcars,
extensions = c("ColReorder"),
options = list(colReorder = TRUE))
但是,在使用 jqui_sortable 添加交互后,列重新排序不再起作用:
library(DT)
library(ggplot2)
server <- function(input, output) {
output$tb <-renderDataTable({
datatable(mtcars,
extensions = c("ColReorder"),
options = list(colReorder = TRUE))
})
output$gg <- renderPlot({
ggplot(mtcars, aes(x = cyl, y = mpg, color = factor(vs))) +
geom_point() +
theme(legend.position= "none")
})
}
ui <- fluidPage(
jqui_sortable(div(plotOutput('gg', width = '200px', height = '200px'),
dataTableOutput('tb', width = '200px', height = '200px')
))
)
shinyApp(ui, server)
如果您有任何解决方法或其他方法的建议,我将不胜感激:)
【问题讨论】:
标签: javascript r datatables shiny dt