首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用RHandsontable格式化ShinyThemes

用RHandsontable格式化ShinyThemes
EN

Stack Overflow用户
提问于 2019-02-21 09:03:31
回答 1查看 1K关注 0票数 1

我试图在RHandsontable中格式化下拉列表,但没有效果。

以下是一些可复制的代码:

代码语言:javascript
复制
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包覆盖了默认的字体颜色,在下拉菜单的白色背景上使字体颜色变为白色。我找到了一些代码,可以将值的字体颜色在表中更改为灰色(参见代码)。但是,这种字体颜色不适用于下拉菜单。

如何更改字体颜色和/或下拉菜单的背景?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-21 09:39:15

使用此CSS:

代码语言:javascript
复制
css <- "
.handsontable.listbox td {
  background: black;
}
.handsontable.listbox td.htDimmed {
  color: red;
}
.handsontable.listbox tr:hover td {
  background: yellow; 
}
.handsontable.listbox tr td.current {
  background: green; 
}"
ui <- shinyUI(fluidPage(theme = shinytheme("darkly"),
                        tags$head(tags$style(HTML(css))),
                        ......

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54803037

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档