dtedit | R Documentation |
This object will maintain data state. However, in order of the data to persist
between Shiny instances, data needs to be saved to some external format (e.g.
database or R data file). The callback functions provide a mechanism for this
function to interact with a permanent data storage scheme. The callback
functions are called when the user adds, updates, or deletes a row from the
data table. The callback must accept two parameters: data
and row
.
For inserting and updating, the data
object is the current state of
data table including any additions or updates. The row
parameter indicates
which row from data
was modified (or added). For deletions, however,
the data
represents the data table just before deleting the specified
row. That is, if callback.delete
returns a data.frame
, that will
be the new data table; otherwise this function will remove row row
from
data
and that will become the current data table.
dtedit( input, output, name, thedata, id, view.cols = names(thedata), edit.cols = names(thedata), edit.label.cols = edit.cols, input.types, input.choices = NULL, selectize = TRUE, modal.size = "m", text.width = "100%", textarea.width = "570px", textarea.height = "200px", date.width = "100px", numeric.width = "100px", select.width = "100%", defaultPageLength = 10, title.delete = "Delete", title.edit = "Edit", title.add = "New", label.delete = "Delete", label.edit = "Edit", label.add = "New", label.copy = "Copy", show.delete = TRUE, show.update = TRUE, show.insert = TRUE, show.copy = TRUE, callback.delete = function(data, row) { }, callback.update = function(data, olddata, row) { }, callback.insert = function(data, row) { }, click.time.threshold = 2, datatable.options = list(pageLength = defaultPageLength) )
input |
Shiny input object passed from the server. |
output |
Shiny output object passed from the server. |
name |
the name of the UI output. That is, put |
thedata |
a data frame to view and edit. |
view.cols |
character vector with the column names to show in the DataTable.
This can be a subset of the full |
edit.cols |
character vector with the column names the user can edit/add.
This can be a subset of the full |
edit.label.cols |
character vector with the labels to use on the edit
and add dialogs. The length and order of |
input.types |
a character vector where the name corresponds to a column
in |
input.choices |
a list of character vectors. The names of each element in the list must correspond to a column name in the data. The value, a character vector, are the options presented to the user for data entry. |
selectize |
Whether to use selectize.js or not. See |
modal.size |
the size of the modal dialog. See |
text.width |
width of text inputs. |
textarea.width |
the width of text area inputs. |
textarea.height |
the height of text area inputs. |
date.width |
the width of data inputs |
numeric.width |
the width of numeric inputs. |
select.width |
the width of drop down inputs. |
defaultPageLength |
number of rows to show in the data table by default. |
title.delete |
the title of the dialog box for deleting a row. |
title.edit |
the title of the dialog box for editing a row. |
title.add |
the title of the dialog box for inserting a new row. |
label.delete |
the label of the delete button. |
label.edit |
the label of the edit button. |
label.add |
the label of the add button. |
label.copy |
the label of the copy button. |
show.delete |
whether to show/enable the delete button. |
show.update |
whether to show/enable the update button. |
show.insert |
whether to show/enable the insert button. |
show.copy |
whether to show/enablre the copy button. |
callback.delete |
a function called when the user deletes a row. This function should return an updated data.frame. |
callback.update |
a function called when the user updates a row. This function should return an updated data.frame. |
callback.insert |
a function called when the user inserts a new row. This function should return an updated data.frame. |
click.time.threshold |
This is to prevent duplicate entries usually by double clicking the save or update buttons. If the user clicks the save button again within this amount of time (in seconds), the subsequent click will be ignored. Set to zero to disable this feature. For developers, a message is printed using the warning function. |
datatable.options |
options passed to |
The callback functions may throw errors (see e.g. stop
) if there are
problems with data. That is, if data validation checks indicate data problems
before inserting or updating a row the function may throw an error. Note that
the error message will be presented to the user so providing messages
meaningful to the user is recommended. Moreover, if an error is thrown, the
modal dialog is not dismissed and the user can further edit the data and
retry the insertion or update.
Callback functions may return a data.frame
. When a data.frame
is
returned that will become the current state of the data table. If anything
else is returned then the internal data.frame
will be used.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.