Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dataTableOutput

Helper functions for using DT in Shiny


Description

These two functions are like most fooOutput() and renderFoo() functions in the shiny package. The former is used to create a container for table, and the latter is used in the server logic to render the table.

Usage

dataTableOutput(outputId, width = "100%", height = "auto")

DTOutput(outputId, width = "100%", height = "auto")

renderDataTable(
  expr,
  server = TRUE,
  env = parent.frame(),
  quoted = FALSE,
  funcFilter = dataTablesFilter,
  ...
)

renderDT(
  expr,
  server = TRUE,
  env = parent.frame(),
  quoted = FALSE,
  funcFilter = dataTablesFilter,
  ...
)

Arguments

outputId

output variable to read the table from

width

the width of the table container

height

the height of the table container

expr

an expression to create a table widget (normally via datatable()), or a data object to be passed to datatable() to create a table widget

server

whether to use server-side processing. If TRUE, then the data is kept on the server and the browser requests a page at a time; if FALSE, then the entire data frame is sent to the browser at once. Highly recommended for medium to large data frames, which can cause browsers to slow down or crash. Note that if you want to use renderDataTable with shiny::bindCache(), this must be FALSE.

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

funcFilter

(for expert use only) passed to the filter argument of dataTableAjax()

...

ignored when expr returns a table widget, and passed as additional arguments to datatable() when expr returns a data object

References

Examples

if (interactive()) {
  library(shiny)
  library(DT)
  shinyApp(
    ui = fluidPage(fluidRow(column(12, DTOutput('tbl')))),
    server = function(input, output) {
      output$tbl = renderDT(
        iris, options = list(lengthChange = FALSE)
      )
    }
  )
}

DT

A Wrapper of the JavaScript Library 'DataTables'

v0.18
GPL-3 | file LICENSE
Authors
Yihui Xie [aut, cre], Joe Cheng [aut], Xianying Tan [aut], JJ Allaire [ctb], Maximilian Girlich [ctb], Greg Freedman Ellis [ctb], Johannes Rauh [ctb], jQuery contributors [ctb, cph] (jQuery in htmlwidgets/lib), SpryMedia Limited [ctb, cph] (DataTables in htmlwidgets/lib), Brian Reavis [ctb, cph] (selectize.js in htmlwidgets/lib), Leon Gersen [ctb, cph] (noUiSlider in htmlwidgets/lib), Bartek Szopka [ctb, cph] (jquery.highlight.js in htmlwidgets/lib), RStudio, PBC [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.