Register a data object in a shiny session for DataTables
This function stores a data object in a shiny session and returns a URL that
returns JSON data based on DataTables Ajax requests. The URL can be used as
the url
option inside the ajax
option of the table. It is
basically an implementation of server-side processing of DataTables in R.
Filtering, sorting, and pagination are processed through R instead of
JavaScript (client-side processing).
dataTableAjax(session, data, rownames, filter = dataTablesFilter, outputId)
session |
the |
data |
a data object (will be coerced to a data frame internally) |
rownames |
see |
filter |
(for expert use only) a function with two arguments |
outputId |
the output ID of the table (the same ID passed to
|
Normally you should not need to call this function directly. It is called
internally when a table widget is rendered in a Shiny app to configure the
table option ajax
automatically. If you are familiar with
DataTables' server-side processing, and want to use a custom filter
function, you may call this function to get an Ajax URL.
A character string (an Ajax URL that can be queried by DataTables).
DTApp = function(data, ..., options = list()) { library(shiny) library(DT) shinyApp( ui = fluidPage( title = 'Server-side processing of DataTables', fluidRow( DT::dataTableOutput('tbl') ) ), server = function(input, output, session) { options$serverSide = TRUE options$ajax = list(url = dataTableAjax(session, data, outputId = 'tbl')) # create a widget using an Ajax URL created above widget = datatable(data, ..., options = options) output$tbl = DT::renderDataTable(widget) } ) } if (interactive()) DTApp(iris) if (interactive()) DTApp(iris, filter = 'top')
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.