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];