crudTableServer: Server-part of the CRUD table module

Description Usage Arguments Value See Also Examples

View source: R/crudTableServer.R

Description

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.

Usage

1
2
3
4
5
6

Arguments

id

The ID of the module

dao

Data Access Object (dao) that provides the data storage operations, see e.g. sqlDao or dataFrameDao.

formUI

A function that creates the edit form for the user's data input. Typically, it is a function based on formUI. See examples below.

formServer

A server-side function dual to the formUI argument that handles the actions performed in the edit form. Typically, it is a function created with the formServerFactory. See examples below.

Value

Returns a reactive object that triggers on any data change within the CRUD table.

See Also

crudTableUI

Examples

 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)

beerda/crudtable documentation built on July 13, 2020, 2:16 p.m.