Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

403
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda