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

168
Visualizações
JavaScript function for DT formatting (R shiny)

I need to design the R Shiny data table, using Java Script like that (like stairs on the DT bottom, which shows the prediction values - italic and gray).

enter image description here

I'm trying to use this function (From this question), but all my table is italic starting from 3rd column. How can I fix it? (suppose, that my for loop is incorrect)

  rowCallback <- function(rows){
c(
  "function(row, data, num){",
  sprintf("  var rows = [%s];", paste0(rows-1, collapse = ",")),
  "  for(let j=data.length; j >= 3; j--){",
  "    for(let i=j; i<data.length; i++){",
  "      $('td:eq('+i+')', row)",
  "        .css({'background-color': 'rgb(211,211,211)', 'font-style': 'italic', 'font-color': 'rgb(230,230,230)'});",
  "    }",
  "  }",
  "}"  
)

}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Not tested, I would try:

rowCallback <- c(
  "function(row, data, num, index){",
  "  var ncols = data.length;",
  "  for(let j=ncols; j > ncols-index; j--){",
  "    $('td:eq('+j+')', row)",
  "      .css({'background-color': 'rgb(211,211,211)', 'font-style': 'italic', 'font-color': 'rgb(230,230,230)'});",
  "  }",
  "}"  
)

Notes:

  • You don't need a R function, because the rows argument is not used.

  • $('td:eq('+j+')', row) selects the j-th element of the current row, so you don't have to loop over rows.

about 4 years ago · Juan Pablo Isaza Relatório
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