Learn R Programming

DT (version 0.4)

dataTableProxy: Manipulate an existing DataTables instance in a Shiny app

Description

The function datatableProxy() creates a proxy object that can be used to manipulate an existing DataTables instance in a Shiny app, e.g. select rows/columns, or add rows.

Usage

dataTableProxy(outputId, session = shiny::getDefaultReactiveDomain(), 
    deferUntilFlush = TRUE)

selectRows(proxy, selected)

selectColumns(proxy, selected)

selectCells(proxy, selected)

addRow(proxy, data)

clearSearch(proxy)

selectPage(proxy, page)

updateCaption(proxy, caption)

updateSearch(proxy, keywords = list(global = NULL, columns = NULL))

reloadData(proxy, resetPaging = TRUE, clearSelection = c("all", "none", "row", "column", "cell"))

Arguments

outputId

the id of the table to be manipulated (the same id as the one you used in dataTableOutput())

session

the Shiny session object (from the server function of the Shiny app)

deferUntilFlush

whether an action should be carried out right away, or should be held until after the next time all of the outputs are updated

proxy

a proxy object returned by dataTableProxy()

selected

an integer vector of row/column indices, or a matrix of two columns (row and column indices, respectively) for cell indices; you may use NULL to clear existing selections

data

a single row of data to be added to the table; it can be a matrix or data frame of one row, or a vector or list of row data (in the latter case, please be cautious about the row name: if your table contains row names, here data must also contain the row name as the first element)

page

a number indicating the page to select

caption

a new table caption (see the caption argument of datatable())

keywords

a list of two components: global is the global search keyword of a single character string (ignored if NULL); columns is a character vector of the search keywords for all columns (when the table has one column for the row names, this vector of keywords should contain one keyword for the row names as well)

resetPaging

whether to reset the paging position

clearSelection

which existing selections to clear: it can be any combinations of row, column, and cell, or all for all three, or none to keep current selections (by default, all selections are cleared after the data is reloaded)

References

https://rstudio.github.io/DT/shiny.html