Description Usage Arguments Details Note References Examples
View source: R/shinywrappers.R
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.
1 2 3 | renderDataTable(expr, options = NULL, searchDelay = 500,
callback = "function(oTable) {}", escape = TRUE, env = parent.frame(),
quoted = FALSE, outputArgs = list())
|
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/extensions/). |
escape |
Whether to escape HTML entities in the table: |
env |
The environment in which to evaluate |
quoted |
Is |
outputArgs |
A list of arguments to be passed through to the implicit
call to |
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. Note this only applies to the root-level elements of the
options list, and the I() notation does not work for lower-level
elements in the list.
This function only provides the server-side version of DataTables
(using R to process the data object on the server side). There is a
separate package DT (https://github.com/rstudio/DT) that allows
you to create both server-side and client-side DataTables, and supports
additional DataTables features. Consider using DT::renderDataTable()
and DT::dataTableOutput() (see
http://rstudio.github.io/DT/shiny.html for more information).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ## 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.');}")
)
)
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.