我想在闪亮的app中冻结数据表的页眉和页脚。我研究过并找到了这个链接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)
谢谢, SJB。