Skip to content

Commit

Permalink
add DTOutput() and renderDT() to avoid collisions with shiny (really …
Browse files Browse the repository at this point in the history
…should have done this from Day 1)

might be relevant to #379
  • Loading branch information
yihui committed Jan 5, 2018
1 parent 5154bc1 commit f27ce32
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(DTOutput)
export(JS)
export(addRow)
export(clearSearch)
Expand All @@ -16,6 +17,7 @@ export(formatSignif)
export(formatString)
export(formatStyle)
export(reloadData)
export(renderDT)
export(renderDataTable)
export(replaceData)
export(saveWidget)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## NEW FEATURES

- Added functions `DTOutput()` and `renderDT()` as aliases of `dataTableOutput()` and `renderDataTable()`, respectively. This is because the latter often collide with functions of the same names in **shiny**. You are recommended to use `DTOutput()` and `renderDT()` in Shiny apps (unless you always use the `DT::` qualifier).

- Added an argument `params` to the `formatDate()` function so you can pass a list of parameters to the specific date conversion method (http://stackoverflow.com/q/38875173/559676).

- The arguments `interval`, `mark`, and `dec.mark` also work for functions `formatPercentage()`, `formatRound()`, and `formatSignif()` now (thanks, @paulofelipe, #128).
Expand Down
13 changes: 11 additions & 2 deletions R/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
#' @examples # !formatR
#' if (interactive()) {
#' library(shiny)
#' library(DT)
#' shinyApp(
#' ui = fluidPage(fluidRow(column(12, DT::dataTableOutput('tbl')))),
#' ui = fluidPage(fluidRow(column(12, DTOutput('tbl')))),
#' server = function(input, output) {
#' output$tbl = DT::renderDataTable(
#' output$tbl = renderDT(
#' iris, options = list(lengthChange = FALSE)
#' )
#' }
Expand All @@ -31,6 +32,10 @@ dataTableOutput = function(outputId, width = '100%', height = 'auto') {
)
}

#' @export
#' @rdname dataTableOutput
DTOutput = dataTableOutput

#' @export
#' @rdname dataTableOutput
#' @inheritParams shiny::renderDataTable
Expand Down Expand Up @@ -119,6 +124,10 @@ renderDataTable = function(expr, server = TRUE, env = parent.frame(), quoted = F
func
}

#' @export
#' @rdname dataTableOutput
renderDT = renderDataTable

#' Manipulate an existing DataTables instance in a Shiny app
#'
#' The function \code{datatableProxy()} creates a proxy object that can be used
Expand Down
11 changes: 9 additions & 2 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 f27ce32

Please sign in to comment.