Output and render functions for using datagrid()
within Shiny
applications and interactive Rmd documents.
Usage
datagridOutput(outputId, width = "100%", height = "400px")
renderDatagrid(expr, env = parent.frame(), quoted = FALSE)
renderDatagrid2(expr, env = parent.frame(), quoted = FALSE)
datagridOutput2(outputId, width = "100%", height = "auto")
Arguments
- outputId
Output variable to read from.
- width, height
Must be a valid CSS unit (like
100%
,400px
,auto
) or a number, which will be coerced to a string and havepx
appended.- expr
An expression that generates a calendar
- env
The environment in which to evaluate
expr
.- quoted
Is
expr
a quoted expression (withquote()
)? This is useful if you want to save an expression in a variable.
Special inputs
The following input
values will be accessible in the server:
input$outputId_data : contain the data displayed in grid, only available when
datagrid(data_as_input = TRUE)
or when usinggrid_editor()
input$outputId_validation : contain results of validation rules applied to data, only available when using
validation
argument ingrid_editor()
These other inputs can be defined using other functions:
row selection: giving row selected with checkboxes or radio buttons in
inputId
defined ingrid_selection_row()
cell selection: giving cell selected with mouse in
inputId
defined ingrid_selection_cell()
cell clicked: giving row index and column name of cell clicked in
inputId
defined ingrid_click()
Examples
library(shiny)
library(toastui)
ui <- fluidPage(
tags$h2("datagrid shiny example"),
tabsetPanel(
tabPanel(
title = "Fixed height",
datagridOutput("default"),
tags$b("CHECK HEIGHT")
),
tabPanel(
title = "Full height",
datagridOutput("fullheight", height = "auto"),
tags$b("CHECK HEIGHT")
),
tabPanel(
title = "Pagination",
datagridOutput("pagination", height = "auto"),
tags$b("CHECK HEIGHT")
)
)
)
server <- function(input, output, session) {
output$default <- renderDatagrid({
datagrid(rolling_stones_500)
})
output$fullheight <- renderDatagrid({
datagrid(rolling_stones_500, bodyHeight = "auto")
})
output$pagination <- renderDatagrid({
datagrid(rolling_stones_500, pagination = 15)
})
}
if (interactive())
shinyApp(ui, server)