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

169
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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