我想冻结闪亮应用程序中数据表的页眉和页脚。我已经研究并发现了这个链接
https://datatables.net/examples/basic_init/scroll_xy.html
.但当我包含上面链接中的脚本时,数据表不会冻结。请帮我解决这个问题。
library(shiny)
library(shinydashboard)
ui <- dashboardPage(skin = "black",
dashboardHeader(title = "test"),
dashboardSidebar(
sidebarMenu(
menuItem("Complete", tabName = "comp"))),
dashboardBody(useShinyjs(),
tabItems(
tabItem(tabName = "comp",
fluidRow(
box(title = "data", width = 12, solidHeader = TRUE, status = "primary",
collapsible = TRUE, dataTableOutput("tbe")))))))
server <- function(input, output, session) {
output$tbe <- renderDataTable(mtcars)
observe({
runjs("
$(document).ready(function() {
$('#DataTables_Table_0').DataTable( {
\"scrollY\": 200,
\"scrollX\": true
} );
} );
")
})
}
shinyApp(ui, server)
谢谢,
上海交大。