Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ShinyThemes格式化RHandsontable_R_Shiny_Rhandsontable_Shinythemes - Fatal编程技术网

使用ShinyThemes格式化RHandsontable

使用ShinyThemes格式化RHandsontable,r,shiny,rhandsontable,shinythemes,R,Shiny,Rhandsontable,Shinythemes,我试图在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 exa

我试图在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)

库(闪亮)
图书馆(dplyr)
DF使用这个CSS:

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))),
                        ......
css使用此css:

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))),
                        ......

css是的。非常感谢。我应该在花两个小时写这篇文章之前把它放在一起。。。或者也许这个练习对我有好处:)@Caleb很乐意帮忙。请考虑一下。否则,您的问题将被视为SO未回答。是的,正在等待能够实施以确认其有效性。干杯,成功了。非常感谢。我应该在花两个小时写这篇文章之前把它放在一起。。。或者也许这个练习对我有好处:)@Caleb很乐意帮忙。请考虑一下。否则,您的问题将被视为SO未回答。是的,正在等待能够实施以确认其有效性。干杯,成功了。