【发布时间】:2022-01-02 17:15:31
【问题描述】:
当用户取消选中其中一个单元格中的复选框时,我想更改整行的颜色。 (可以是多行)
到目前为止,我只能更改包含复选框的单元格的颜色,而不是整行。在这个例子中,整行 6 应该是彩色的。
library(shiny)
library(rhandsontable)
# Define UI for application that draws a histogram
ui <- fluidPage(
rHandsontableOutput('table')
)
# Define server logic required to draw a histogram
server <- function(input, output) {
df <- data.frame(alphabet = letters[1:10],
include = TRUE)
output$table <- rhandsontable::renderRHandsontable({
rhandsontable(df, height = 500) %>%
hot_col(col = "include",
renderer = "
function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.CheckboxRenderer.apply(this, arguments);
var col_value = instance.getData()[row][1]
if (col_value === false) {
td.style.background = 'pink';
}
}
")
})
}
# Run the application
shinyApp(ui = ui, server = server)
【问题讨论】:
标签: javascript r shiny rhandsontable