Description Usage Arguments Value See Also Examples
View source: R/crudTableServer.R
This is the server-part of the module. It handles all the CRUD (Create, Read, Update, Delete)
operations on data. For new or existing data input, a modal dialog is opened that is defined by
the formUI
and formServer
arguments. The underlying data table is accessed via the
dao
object.
1 2 3 4 5 6 | crudTableServer(
id,
dao,
formUI = simpleFormUIFactory(dao),
formServer = formServerFactory(dao)
)
|
id |
The ID of the module |
dao |
Data Access Object ( |
formUI |
A function that creates the edit form for the user's data input. Typically, it
is a function based on |
formServer |
A server-side function dual to the |
Returns a reactive object that triggers on any data change within the CRUD table.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ## Not run:
library(shiny)
library(crudtable)
# Create Data Access Object
dao <- dataFrameDao(CO2)
# Create edit form dialog
myFormUI <- function(id) {
ns <- NS(id)
formUI(id,
selectInput(ns('Plant'), 'Plant', choices = levels(CO2$Plant)),
selectInput(ns('Type'), 'Type', choices = levels(CO2$Type)),
selectInput(ns('Treatment'), 'Treatment', choices = levels(CO2$Treatment)),
numericInput(ns('conc'), 'Ambient CO2 concentration [ml/L]',
value = 100, min = 50, max = 1000),
numericInput(ns('uptake'), 'CO2 uptake rates [umol/m2 sec]',
value = 0, min = 0, max = 100),
)
}
# Create edit form dialog handler
myFormServer <- formServerFactory(dao)
# User Interface
ui <- fluidPage(
crudTableUI('crud')
)
# Server-side
server <- function(input, output, session) {
crudTableServer('crud', dao, myFormUI, myFormServer)
}
# Run the shiny app
shinyApp(ui = ui, server = server)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.