Javascript 具有行高亮显示和复选框列的rhandsontable

Javascript 具有行高亮显示和复选框列的rhandsontable,javascript,r,shiny,handsontable,rhandsontable,Javascript,R,Shiny,Handsontable,Rhandsontable,我试图使用rhandsontable库来生成一个表,在这个表中我结合了包的两个漂亮特性:(1)使用customerrenderer参数突出显示行,以及(2)布尔字段的复选框列类型 就其本身而言,这两个功能都可以很好地工作。例如,下面显示了行高亮显示的工作原理: library(rhandsontable) df = data.frame(val = 1:10, bool = TRUE, big = LETTERS[1:10], small = letters[1:

我试图使用
rhandsontable
库来生成一个表,在这个表中我结合了包的两个漂亮特性:(1)使用customer
renderer
参数突出显示行,以及(2)布尔字段的复选框列类型

就其本身而言,这两个功能都可以很好地工作。例如,下面显示了行高亮显示的工作原理:

library(rhandsontable)
df = data.frame(val = 1:10, bool = TRUE, big = LETTERS[1:10],
                small = letters[1:10],
                stringsAsFactors = FALSE)

row_highlight = c(5, 7)

rhandsontable(df,
              row_highlight = row_highlight) %>%
hot_cols(renderer = "
  function(instance, td, row, col, prop, value, cellProperties) {
    Handsontable.renderers.TextRenderer.apply(this, arguments);

    tbl = this.HTMLWidgets.widgets[0]

    hrows = tbl.params.row_highlight
    hrows = hrows instanceof Array ? hrows : [hrows] 

    if (hrows.includes(row)) {
      td.style.background = 'pink';
    }

    return td;
}") 
library(rhandsontable)
df = data.frame(val = 1:10, bool = TRUE, big = LETTERS[1:10],
                small = letters[1:10],
                stringsAsFactors = FALSE)

rhandsontable(df, row_highlight = row_highlight) %>%
  hot_col(col = 'bool', type = 'checkbox')
下面显示了复选框功能的工作原理:

library(rhandsontable)
df = data.frame(val = 1:10, bool = TRUE, big = LETTERS[1:10],
                small = letters[1:10],
                stringsAsFactors = FALSE)

row_highlight = c(5, 7)

rhandsontable(df,
              row_highlight = row_highlight) %>%
hot_cols(renderer = "
  function(instance, td, row, col, prop, value, cellProperties) {
    Handsontable.renderers.TextRenderer.apply(this, arguments);

    tbl = this.HTMLWidgets.widgets[0]

    hrows = tbl.params.row_highlight
    hrows = hrows instanceof Array ? hrows : [hrows] 

    if (hrows.includes(row)) {
      td.style.background = 'pink';
    }

    return td;
}") 
library(rhandsontable)
df = data.frame(val = 1:10, bool = TRUE, big = LETTERS[1:10],
                small = letters[1:10],
                stringsAsFactors = FALSE)

rhandsontable(df, row_highlight = row_highlight) %>%
  hot_col(col = 'bool', type = 'checkbox')
我的问题:如何结合这两个功能(即,生成一个带有高亮显示行和功能复选框的表)

人们可能会认为下面的方法可行,但复选框不会呈现(而是显示为
true
false
):


有没有一种方法可以在R中的rhandsontable中同时组合复选框和行高亮显示?

应将不同的呈现器应用于具有文本/数字和逻辑变量的列,以便组合复选框功能和行高亮显示

library(rhandsontable)
df = data.frame(val = 1:10, bool = TRUE, big = LETTERS[1:10],
                small = letters[1:10],
                stringsAsFactors = FALSE)

row_highlight = c(5, 7)

rhandsontable(df,
              row_highlight = row_highlight) %>%
  hot_col(col = names(df)[!names(df) %in% "bool"], 
          renderer = "
          function(instance, td, row, col, prop, value, cellProperties) {
            Handsontable.renderers.TextRenderer.apply(this, arguments);

            tbl = this.HTMLWidgets.widgets[0]

            hrows = tbl.params.row_highlight
            hrows = hrows instanceof Array ? hrows : [hrows] 

            if (hrows.includes(row)) {
              td.style.background = 'pink';
            }

            return td;
          }") %>%
  hot_col(col = "bool",
          renderer = "
          function(instance, td, row, col, prop, value, cellProperties) {
            Handsontable.renderers.CheckboxRenderer.apply(this, arguments);

            tbl = this.HTMLWidgets.widgets[0]

            hrows = tbl.params.row_highlight
            hrows = hrows instanceof Array ? hrows : [hrows] 

            if (hrows.includes(row)) {
              td.style.background = 'pink';
            }

            return td;
          }")