【发布时间】:2019-07-15 03:04:57
【问题描述】:
我正在尝试在 RHandsontable 中格式化下拉列表,但无济于事。
这是一些可重现的代码:
library(shiny)
library(dplyr)
DF <- data.frame(Value = 1:10)
choices <- 1:20
ui <- shinyUI(fluidPage(theme = shinytheme("darkly"),
rHandsontableOutput("hot")
,h4("This is example text from the theme.")
))
server = (function(input, output) {
values <- reactiveValues()
## Handsontable
observe({
if (!is.null(input$hot)) {
values[["previous"]] <- isolate(values[["DF"]])
DF = hot_to_r(input$hot)
} else {
if (is.null(values[["DF"]]))
DF <- DF
else
DF <- values[["DF"]]
}
values[["DF"]] <- DF
})
output$hot <- renderRHandsontable({
DF <- values[["DF"]]
if (!is.null(DF)) {
rhandsontable(DF) %>%
hot_col(col = c("Value"), type = "dropdown", source = choices, strict = TRUE, allowInvalid = FALSE) %>%
hot_cols(renderer = "
function(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.DropdownRenderer.apply(this, arguments);
td.style.color = 'gray';
}
")
}
})
})
shinyApp(ui = ui, server = server)
我遇到的问题是 ShinyThemes 包覆盖了默认字体颜色,使下拉菜单的白色背景上的字体颜色为白色。我发现了一些代码将 in 表中值的字体颜色更改为灰色(参见代码)。但是,此字体颜色不适用于下拉菜单。
如何更改下拉菜单的字体颜色和/或背景?
【问题讨论】:
标签: r shiny rhandsontable shinythemes