Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

406
Vistas
How to conditionally color cells by referring to values of other cell (Rhandsontable/CSS)

I have a table in following format(column headers as well as From/To refer to months) The columns refer to distinct numerical months(which will always be a multiple of 12) for which I am providing year by year value. For the periods where it doesn't make sense (eg month 25 onwards for a 20 month column), I want to blackout the fields. So I wanna arrive from : enter image description here

to this:

enter image description here

Here's the code that's helping me get started on this but I'm not sure for a cell how can I refer to its column name, as well as respective 'To' column

library(dplyr)
library(rhandsontable)
colheaders<-c(24,36,48,60)
df<-matrix(0,nrow = ceiling(max(colheaders)/12), ncol=length(colheaders)+2) %>% 
  data.frame() %>%
  `colnames<-`(c('From','To',colheaders)) %>%
  mutate(From=c(1:ceiling(max(colheaders)/12))*12-11) %>%
  mutate(To=c(1:ceiling(max(colheaders)/12))*12)
rhandsontable(df) %>%
  hot_col(as.character(colheaders), format = "0.00%") %>%
  hot_col(c("From","To"), format = "0", readOnly = T) %>%
  hot_cols(renderer = "
           function (instance, td, row, col, prop, value, cellProperties) {
             Handsontable.renderers.NumericRenderer.apply(this, arguments);
             if (col < row) {
              td.style.background = 'grey';
              td.style.color = 'grey';
             }
           }")

If I can get help write a logic that - for each cell, if's respective To's value is greater than column name, black it out(eg every cell of column 24 is compared with 12, 24, 36 etc and 36 on it is blacked) it's help unblock me. Appreciate any help on this.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda