Table output with the JavaScript DataTables library — dataTableOutput
R/bootstrap.R
, R/shinywrappers.R
Description
This function is deprecated, use DT::renderDT() instead. It provides a superset of functionality, better performance, and better user experience.
Arguments
- outputId
output variable to read the table from
- expr
An expression that returns a data frame or a matrix.
- options
A list of initialization options to be passed to DataTables, or a function to return such a list. You can find a complete list of options at https://datatables.net/reference/option/.
Any top-level strings with class
"AsIs"
(as created byI()
) will be evaluated in JavaScript. This is useful when the type of the option value is not supported in JSON, e.g., a JavaScript function, which can be obtained by evaluating a character string. This only applies to the root-level elements of options list, and does not worked for lower-level elements in the list.- searchDelay
The delay for searching, in milliseconds (to avoid too frequent search requests).
- callback
A JavaScript function to be applied to the DataTable object. This is useful for DataTables plug-ins, which often require the DataTable instance to be available.
- escape
Whether to escape HTML entities in the table:
TRUE
means to escape the whole table, andFALSE
means not to escape it. Alternatively, you can specify numeric column indices or column names to indicate which columns to escape, e.g.1:5
(the first 5 columns),c(1, 3, 4)
, orc(-1, -3)
(all columns except the first and third), orc('Species', 'Sepal.Length')
.- env
The parent environment for the reactive expression. By default, this is the calling environment, the same as when defining an ordinary non-reactive expression. If
expr
is a quosure andquoted
isTRUE
, thenenv
is ignored.- quoted
If it is
TRUE
, then thequote()
ed value ofexpr
will be used whenexpr
is evaluated. Ifexpr
is a quosure and you would like to use its expression as a value forexpr
, then you must setquoted
toTRUE
.- outputArgs
A list of arguments to be passed through to the implicit call to
dataTableOutput()
whenrenderDataTable()
is used in an interactive R Markdown document.
Examples
## Only run this example in interactive R sessions
if (interactive()) {
# pass a callback function to DataTables using I()
shinyApp(
ui = fluidPage(
fluidRow(
column(12,
dataTableOutput('table')
)
)
),
server = function(input, output) {
output$table <- renderDataTable(iris,
options = list(
pageLength = 5,
initComplete = I("function(settings, json) {alert('Done.');}")
)
)
}
)
}