Table output with the JavaScript library DataTables

renderDataTable(expr, options = NULL, searchDelay = 500, callback = "function(oTable) {}", env = parent.frame(), quoted = FALSE)

Arguments

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.
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 (http://datatables.net/extras/).
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.

Table output with the JavaScript library DataTables

Description

Makes a reactive version of the given function that returns a data frame (or matrix), which will be rendered with the DataTables library. Paging, searching, filtering, and sorting can be done on the R side using Shiny as the server infrastructure.

Details

For the options argument, the character elements that have the class "AsIs" (usually returned from I()) 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.

Examples

# pass a callback function to DataTables using I() renderDataTable(iris, options = list( iDisplayLength = 5, fnInitComplete = I("function(oSettings, json) {alert('Done.');}") ) )
function(shinysession, name, ...) { res <- checkAsIs(if (is.function(options)) options() else options) data <- func() if (length(dim(data)) != 2) return() # expects a rectangular data object action <- shinysession$registerDataObj(name, data, dataTablesJSON) list( colnames = colnames(data), action = action, options = res$options, evalOptions = if (length(res$eval)) I(res$eval), searchDelay = searchDelay, callback = paste(callback, collapse = '\n') ) } <environment: 0x57f4f18> attr(,"class") [1] "shiny.render.function" "function" attr(,"outputFunc") function (outputId) { attachDependencies(div(id = outputId, class = "shiny-datatable-output"), dataTableDependency) } <environment: namespace:shiny>