Skip to content

Commit

Permalink
Add renderDT(outputArgs=), remove doc dependency on deprecated Shiny …
Browse files Browse the repository at this point in the history
…funcs

We're transitioning toward removing shiny::dataTableOutput and shiny::renderDataTable
and having them shim their DT equivalents.
  • Loading branch information
jcheng5 committed Mar 12, 2024
1 parent 06d3ae6 commit 1bdc87b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CHANGES IN DT VERSION 0.33

- Added `outputArgs` parameter to `renderDataTable`, to allow width and height to be set when using interactive R Markdown documents.

# CHANGES IN DT VERSION 0.32

Expand Down
23 changes: 19 additions & 4 deletions R/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' functions in the \pkg{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.
#' @inheritParams shiny::dataTableOutput
#' @param outputId output variable to read the table from
#' @param width the width of the table container
#' @param height the height of the table container
#' @param fill passed to \code{htmlwidgets::\link{shinyWidgetOutput}()}, see
Expand Down Expand Up @@ -42,7 +42,6 @@ DTOutput = dataTableOutput

#' @export
#' @rdname dataTableOutput
#' @inheritParams shiny::renderDataTable
#' @param expr an expression to create a table widget (normally via
#' \code{\link{datatable}()}), or a data object to be passed to
#' \code{datatable()} to create a table widget
Expand All @@ -53,17 +52,31 @@ DTOutput = dataTableOutput
#' browsers to slow down or crash. Note that if you want to use
#' \code{renderDataTable} with \code{shiny::bindCache()}, this must be
#' \code{FALSE}.
#' @param 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 \code{expr} is a quosure and \code{quoted} is
#' \code{TRUE}, then \code{env} is ignored.
#' @param quoted If it is \code{TRUE}, then the
#' \code{\link[substitute]{quote}()}ed value of \code{expr} will be used when
#' \code{expr} is evaluated. If \code{expr} is a quosure and you would like to
#' use its expression as a value for \code{expr}, then you must set
#' \code{quoted} to \code{TRUE}.
#' @param funcFilter (for expert use only) passed to the \code{filter} argument
#' of \code{\link{dataTableAjax}()}
#' @param future whether the server-side filter function should be executed
#' as a future or as a standard synchronous function. If true, the future
#' will be evaluated according to the session's \link[future]{plan}.
#' @param outputArgs A list of arguments to be passed through to the implicit
#' call to \code{\link{dataTableOutput}()} when
#' \code{\link{renderDataTable}()} is used in an interactive R Markdown
#' document.
#' @param ... ignored when \code{expr} returns a table widget, and passed as
#' additional arguments to \code{\link{datatable}()} when \code{expr} returns
#' a data object
renderDataTable = function(
expr, server = TRUE, env = parent.frame(), quoted = FALSE,
funcFilter = dataTablesFilter, future = FALSE, ...
funcFilter = dataTablesFilter, future = FALSE,
outputArgs = list(), ...
) {
if (!quoted) expr = substitute(expr)

Expand Down Expand Up @@ -172,6 +185,7 @@ renderDataTable = function(
removeTimestampFromSnapshot(name)
promises::with_promise_domain(domain, renderFunc())
},
outputArgs = outputArgs,
cacheHint = cacheHint
)
} else {
Expand All @@ -181,7 +195,8 @@ renderDataTable = function(
domain = tempVarsPromiseDomain(outputInfoEnv, outputName = name, session = shinysession)
removeTimestampFromSnapshot(name)
promises::with_promise_domain(domain, renderFunc())
}
},
outputArgs = outputArgs
)
}

Expand Down
18 changes: 13 additions & 5 deletions man/dataTableOutput.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1bdc87b

Please sign in to comment.