我想通过包含jQuery UI在一个闪亮的应用程序中隐藏DataTables。我在标题中集成了标签,但未考虑样式。
示例代码:
library(shiny)
runApp(list(
ui= pageWithSidebar(
headerPanel(list('Examples of DataTables',
singleton(tags$head(tags$link(rel = "stylesheet", type ="text/css", href = "https://cdn.datatables.net/v/ju-1.11.4/dt-1.10.13/datatables.min.css"))),
singleton(tags$head(tags$script(type='text/javascript',src='https://cdn.datatables.net/v/ju-1.11.4/dt-1.10.13/datatables.min.js'))))),
sidebarPanel(
checkboxGroupInput('show_vars',
'Columns in diamonds to show:',
names(diamonds),
selected = names(diamonds))
),
mainPanel(
tabsetPanel(
tabPanel('diamonds',
dataTableOutput("mytable1")),
tabPanel('mtcars',
dataTableOutput("mytable2")),
tabPanel('iris',
dataTableOutput("mytable3"))
))),
server = function(input, output) {
output$mytable1 = renderDataTable({
library(ggplot2)
diamonds[, input$show_vars, drop = FALSE]
})
output$mytable2 = renderDataTable({mtcars}, options = list(orderClasses = TRUE))
output$mytable3 = renderDataTable({
iris}, options = list(lengthMenu = c(5, 30, 50), pageLength = 5))
}))
我想显示数据表,如以下示例所示,取自
https://datatables.net/manual/styling/jqueryui
最佳答案
当我在浏览器中打开表时,它的工作原理是这样的,而在RStudio查看器中却不起作用。那应该可以在Shiny中使用,但是DT javascript提供的所有功能都将丢失。
dtable <- datatable(iris)
dep <- htmltools::htmlDependency(
"judtcss", "1.11.4",
c(href = "https://cdn.datatables.net/v/ju-1.11.4/dt-1.10.13/"),
stylesheet = "datatables.min.css")
dtable$dependencies <- c(dtable$dependencies, list(dep))
dep <- htmltools::htmlDependency(
"judt", "1.11.4",
c(href = "https://cdn.datatables.net/v/ju-1.11.4/dt-1.10.13/"),
script = "datatables.min.js")
dtable$dependencies <- c(dtable$dependencies, list(dep))
dtable$dependencies[[1]] <- NULL
dtable
关于jquery - 通过包含针对DataTables的jQuery UI集成,在 Shiny 的应用程序中隐藏DataTables,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43075882/