I'd like to create a validation scheme when a table based on "rhandsontable" is updated. I have two columns: Min and Max and I'd like that when a cell in the column Max is updated, only it's allowed updating with a value greater than the previous column Min in the same row or vice-versa. Maybe it's possible using hot_cols renderer and validating by means of subtraction greater than zero, etc. but I'm not familiar with "rhandsontable" or "hansontable" in general although I think this is possible, but I don't know how. Thanks.
Toy example:
library(shiny)
library(rhandsontable)
if (interactive()) {
ui <- fluidPage(
rHandsontableOutput('table'),
tableOutput('table1')
)
server <- function(input, output,session) {
values <- reactiveValues(df=data.frame(Parameter=c('A','B','C'),Min=c(10,20,30),Max=c(20,30,40)))
observe({
if(!is.null(input$table)){
values$df <- hot_to_r(input$table)
output$table1<-renderTable(values$df)
}
})
output$table<-renderRHandsontable({
rhandsontable(values$df)%>%
hot_col("Parameter", readOnly = TRUE)%>%
hot_validate_numeric(col='Min', min = 1, max = 50,allowInvalid = FALSE)%>%
hot_validate_numeric(col='Max', min = 1, max = 50,allowInvalid = FALSE)
})
}
shinyApp(ui, server)
}