R/callback.R

Defines functions callback

Documented in callback

#' @name callback
#' @title Table with collapsible rows (2)
#' @author Nicolas Mangin
#' @description Function formatting references with collapsible rows
#' @param x Dataframe. Table of references.
#' @param pos Integer. Position of the row.
#' @return A datatable with collapsed rows.
#' @export


callback <- function(x, pos = NULL) {
  part1 <- "table.column(1).nodes().to$().css({cursor: 'pointer'});"
  part2 <- bibliogR::child_row_table(x, pos = pos)
  part3 <- "
   table.on('click', 'td.details-control', function() {
    var td = $(this), row = table.row(td.closest('tr'));
    if (row.child.isShown()) {
      row.child.hide();
      td.html('&oplus;');
    } else {
      row.child(format(row.data())).show();
      td.html('&ominus;');
    }
  });"
  base::paste(part1, part2, part3)
}
NicolasJBM/bibliogR documentation built on April 21, 2024, 12:16 a.m.