我想根据值对整行应用颜色突出显示并保留 rhandsontable 的复选框功能。在下面的简单示例中,我希望第 3 行为粉红色,第 4 行为绿色。
library(rhandsontable)
DF = data.frame( bool = TRUE,val = 1:10, big = LETTERS[1:10],
small = letters[1:10],
stringsAsFactors = FALSE)
###Checkboxes not Present/Entire row not highlighted
rhandsontable(DF, readOnly = FALSE, width = 750, height = 300) %>%
hot_cols(renderer = "
function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.NumericRenderer.apply(this, arguments);
if (value == 'C') {
td.style.background = 'pink';
} else if (value == 'D') {
td.style.background = 'green';
}
}")
####Checkboxes Present
rhandsontable(DF, readOnly = FALSE, width = 750, height = 300)