Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!