Skip to contents

Add rows to an existent datagrid

Usage

grid_proxy_add_row(proxy, data)

Arguments

proxy

A datagrid_proxy() or outputId of the grid.

data

data.frame to append in the grid.

Value

A datagrid_proxy object.

See also

Other datagrid proxy methods: datagrid_proxy(), grid_proxy_delete_row()

Examples

library(shiny)
library(toastui)

ui <- fluidPage(
  tags$h2("Append row to grid"),
  datagridOutput("grid"),
  actionButton(
    inputId = "add",
    label = "Add row",
    class = "btn-block"
  )
)

server <- function(input, output, session) {

  dat <- data.frame(
    character = month.name,
    select = month.name,
    checkbox = month.abb,
    radio = month.name,
    password = month.name
  )

  output$grid <- renderDatagrid({
    datagrid(rolling_stones_50[1, ])
  })

  value <- reactiveVal(1)
  observeEvent(input$add, {
    row <- value() + 1
    grid_proxy_add_row(
      proxy = "grid",
      data = rolling_stones_50[row, ]
    )
    value(row)
  })

}

if (interactive())
  shinyApp(ui, server)