R/dt_opts.R

Defines functions dt_opts

Documented in dt_opts

#' Dynamic Table / Datatable Options
#'
#' @description The default dynamic table options
#' set for use in development.  Currently in use for
#' SOKRR application

dt_opts<-function(){
  list(
    dom = 'Bfrtip',
    # rowsGroup = list(0, 1),
    fixedColumns = list(leftColumns = 2),
    lengthMenu = list(c(5, 15, -1), c('5', '15', 'All')),
    pageLength = 20,
    searching = FALSE,
    buttons = list(
      list(
        extend = "collection",
        text = 'Show All',
        action = DT::JS(
          "function ( e, dt, node, config ) {
                                    dt.page.len(-1);
                                    dt.ajax.reload();
                                }"
        )
      ),
      list(
        extend = "collection",
        text = 'Show Less',
        action = DT::JS(
          "function ( e, dt, node, config ) {
                              dt.page.len(10);
                              dt.ajax.reload();}"
        )

      )
    ),
    autoWidth = F,
    paging = T,
    select = F,
    processing = F,
    columnDefs = list(list(
      targets = list(3:4),
      render = DT::JS("function(data) {",
                      "return (data / 1000).toFixed(1) + 'K'",
                      "}")
    )),
    ordering = T,
    scrollX = T,
    scrollY = T
  )
}
HarryRosen/hrimodules documentation built on Jan. 11, 2022, 12:36 a.m.