Learn R Programming

editbl (version 1.3.0)

eDTOutput: UI part of eDT

Description

UI part of eDT

Usage

eDTOutput(id, ...)

Value

HTML

Arguments

id

character(1)

...

arguments passed to DTOutput

Author

Jasper Schelfhout

Details

Works exactly like DTOutput apart from the fact that instead of the outputId argument, id is requested. Reason being that this function is a UI to a shiny module. This means that the datatable can be found under the id '{namespace}-{id}-DT' instead of '{namespace}-{outputId}'.

Also some minor CSS and javascript is executed for functional puposes.

Examples

Run this code
## Only run this example in interactive R sessions
if(interactive()){
  # tibble support
  modifiedData <- editbl::eDT(tibble::as_tibble(mtcars))

  # data.table support
  modifiedData <- editbl::eDT(dtplyr::lazy_dt(data.table::data.table(mtcars)))

  # database support
  tmpFile <- tempfile(fileext = ".sqlite")
  file.copy(system.file("extdata", "chinook.sqlite", package = 'editbl'), tmpFile)

  conn <- editbl::connectDB(dbname = tmpFile)
  modifiedData <- editbl::eDT(dplyr::tbl(conn, "Artist"), in_place = TRUE)
  DBI::dbDisconnect(conn)

  unlink(tmpFile)

  # Within shiny
  library(shiny)
  library(editbl)
  shinyApp(
    ui = fluidPage(fluidRow(column(12, eDTOutput('tbl')))),
    server = function(input, output) {
      eDT('tbl',iris,)
    }
  )

  # Custom inputUI
  editbl::eDT(mtcars, inputUI = function(id, data){
    ns <- NS(id)
    textInput(
    ns("mpg"),
    label = "mpg",
    value = data$mpg)})

  # Do not allow delete
  editbl::eDT(mtcars, canDeleteRow = FALSE)
}

Run the code above in your browser using DataLab