DT封装样式问题

时间:2018-07-18 00:25:22

标签: r shiny dt

我的问题与下面的短代码示例有关。

1)为什么backgroundColor只适用于数字而不适用于字母/字符?

2)鼠标悬停时如何禁用行颜色的更改?

3)如何禁用“显示1至5个条目(共5个)”的显示

library(shiny)
library(DT)


test <- data.frame(test1 = c(1:5)) # Colour changes here
#test <- data.frame(test1 = letters[1:5]) # Colour does not change here



ui <- shinyUI(fluidPage(
  DT::dataTableOutput("tt")
)
)

server <- shinyServer(function(input, output) {

  output$tt <- DT::renderDataTable({
    datatable(test, 
              rownames = FALSE,
              colnames = NULL,
              options = list(paging = FALSE, searching = FALSE)) %>% 
      formatStyle("test1", 
                  backgroundColor = styleEqual(c(1, 2), c("grey", "grey")))
  })
})

shinyApp(ui = ui, server = server)

0 个答案:

没有答案