Javascript ColReorder DT扩展与shinyjqui的结合

Javascript ColReorder DT扩展与shinyjqui的结合,javascript,r,datatables,shiny,dt,Javascript,R,Datatables,Shiny,Dt,我的目标是显示一些数据表和: 1) 为所有表启用列排序 2) 启用更改表格顺序 我的第一次尝试是将shinyjqui::jqui_sortable与DT::datatable结合使用 对于列重新排序,ColReorder扩展做得很好,例如 library(DT) datatable(mtcars, extensions = c("ColReorder"), options = list(colReorder = TRUE)) 但是,使用jqui_sort

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

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)
库(DT)
图书馆(GG2)

服务器将
options
参数添加到
jqui\u sortable
函数:
options=list(cancel='.dataTables\u scroll')
。在这种情况下,它取消了类为
.dataTables\u scroll
的元素的排序功能,该类元素是整个表(带有列名)