在闪亮中使用navbarpage时显示的样式标签

时间:2019-07-05 14:34:40

标签: r shiny dt

当我在应用程序中选择行时,我想更改DT中行的颜色,从默认的蓝色。我使用了this answer,它可以工作,但是由于某种原因,它在应用程序中显示了样式标签的文本。

Example of style tag showing

我尝试更改为UserID GiftCardID UseDate OrderID IsUsed 8278020 165491838 2019-03-06 23057796 1 8278020 165491839 2019-03-10 23106429 1 8278020 165491840 2019-03-24 23277217 1 8278020 166418161 NULL NULL 0 8278020 166418162 NULL NULL 0 8278020 167026357 2019-04-22 23594414 1 8278020 167026358 2019-04-28 23668492 1 而不是/include/llvm/Support/Errc.h:66:34: error: 'not_supported' is not a member of 'std::errc' not_supported = int(std::errc::not_supported), ,这解决了这个问题-但我想在导航选项卡中使用navbarPage!

我认为我在做一些愚蠢的事情-有什么想法吗?

示例代码:

fluidPage()

1 个答案:

答案 0 :(得分:2)

只需将style$tag部分放在fluidRow中,它将起作用。您不需要样式标签中的HTML函数:

library(shiny)
library(DT)
library(data.table)

example_data <- data.table(words = c("on", "scone", "wrong", "stone"), 
                           description = c("The word on", "Scone is not on", "Not on either", "Not here at all"))

ui = shinyUI(navbarPage(
  title = "Random example",
      fluidRow(
        tags$style('table.dataTable tr.selected td, table.dataTable td.selected {background-color: cornsilk !important;}'),
        dataTableOutput("word_searched")
      )
)
)


server = shinyServer(function(input, output, session) {

  output$word_searched <- renderDataTable({
    datatable(example_data)
  })

})

shinyApp(ui = ui, server = server)

出局:

enter image description here