Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.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
Javascript 将参数传递给rhandsontable中的自定义渲染器在闪亮的应用程序中不起作用_Javascript_R_Shiny_Rhandsontable - Fatal编程技术网

Javascript 将参数传递给rhandsontable中的自定义渲染器在闪亮的应用程序中不起作用

Javascript 将参数传递给rhandsontable中的自定义渲染器在闪亮的应用程序中不起作用,javascript,r,shiny,rhandsontable,Javascript,R,Shiny,Rhandsontable,我需要将一些参数传递到自定义的rhandsontable渲染器中。在RStudio中执行时,它可以正常工作,但在闪亮的应用程序中使用时,它不会呈现任何内容 以下是设置粗体字体的自定义渲染器的代码: renderSheet <- function(df, bold) { rhandsontable( df, col_bold = bold$col, row_bold = bold$row) %>% hot_cols(r

我需要将一些参数传递到自定义的
rhandsontable
渲染器中。在RStudio中执行时,它可以正常工作,但在闪亮的应用程序中使用时,它不会呈现任何内容

以下是设置粗体字体的自定义渲染器的代码:

renderSheet <- function(df, bold) {
    rhandsontable(
        df,
        col_bold = bold$col,
        row_bold = bold$row) %>%  
    hot_cols(renderer = "
        function(instance, td, row, col, prop, value, cellProperties) {
          Handsontable.renderers.TextRenderer.apply(this, arguments);

          tbl = this.HTMLWidgets.widgets[0]

          col_bold = tbl.params.col_bold
          col_bold = col_bold instanceof Array ? col_bold : [col_bold] 
          row_bold = tbl.params.row_bold
          row_bold = row_bold instanceof Array ? row_bold : [row_bold] 

          if (col_bold.includes(col) && row_bold.includes(row)) {
            td.style.fontWeight = 'bold';
          }

          return td;
    }"
    ) }
我们如何将上述代码片段应用于我的问题

df = data.frame(a = c("a1", "a2"), b = c("b1", "b2"))
bold <- data.frame(row = c(1, 1), col = c(0, 1))
renderSheet(df, bold)
library(rhandsontable) 
library(shiny)

df = data.frame(a = c("a1", "a2"), b = c("b1", "b2"))
bold <- data.frame(row = c(1, 1), col = c(0, 1))


ui <- shinyUI(fluidPage(  
    rHandsontableOutput("hot") 
))

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

    output$hot = renderRHandsontable({
        renderSheet(df, bold)   
    }) 
})

shinyApp(ui, server)
HTMLWidgets.widgets.filter(function(widget) {
  // this should match the table id specified in the shiny app
  return widget.name === "hot"
})[0];