【问题标题】:ColReorder DT extension in combination with shinyjquiColReorder DT 扩展与 shinyjqui 结合使用
【发布时间】:2018-11-24 11:35:12
【问题描述】:

我的目标是显示一些数据表和:

1) 为所有表启用列重新排序

2) 启用更改表顺序。

我的第一次尝试是将shinyjqui::jqui_sortableDT::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


    【解决方案1】:

    options 参数添加到jqui_sortable 函数:options = list(cancel = '.dataTables_scroll')。在这种情况下,它会取消对具有类 .dataTables_scroll 的元素的排序功能,该类是整个表(带有列名)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-20
      • 2021-12-23
      • 2021-10-09
      • 2019-02-28
      相关资源
      最近更新 更多