proxy: Manipulate an existing DataTables instance in a Shiny app

dataTableProxyR Documentation

Manipulate an existing DataTables instance in a Shiny app


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.


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

selectRows(proxy, selected, ignore.selectable = FALSE)

selectColumns(proxy, selected, ignore.selectable = FALSE)

selectCells(proxy, selected, ignore.selectable = FALSE)

addRow(proxy, data, resetPaging = TRUE)


selectPage(proxy, page)

updateCaption(proxy, caption)

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

showCols(proxy, show, reset = FALSE)

hideCols(proxy, hide, reset = FALSE)

colReorder(proxy, order, origOrder = FALSE)

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



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


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


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


a proxy object returned by dataTableProxy()


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


when FALSE (the default), the "non-selectable" range specified by selection = list(selectable= ) is respected, i.e., you can't select "non-selectable" range. Otherwise, it is ignored.


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)


whether to reset the paging position


a number indicating the page to select


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


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)


a vector of column positions to show (the indexing starts at 0, but if row.names are visible, they are the first column).


if TRUE, will only show/hide the columns indicated.


a vector of column positions to hide


A numeric vector of column positions, starting from 0, and including the row.names as a column, if they are include. Must contain a value for all columns, regardless of whether they are visible or not. Also for column reordering to work, the datatable must have extension 'ColReorder' set as well as option 'colReordoer' set to TRUE).


Whether column reordering should be relative to the original order (the default is to compare to current order)


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)


addRow() only works for client-side tables. If you want to use it in a Shiny app, make sure to use renderDataTable(..., server = FALSE). Also note that the column filters (if used) of the table will not be automatically updated when a new row is added, e.g., the range of the slider of a column will stay the same even if you have added a value outside the range of the original data column.

reloadData() only works for tables in the server-side processing mode, e.g. tables rendered with renderDataTable(server = TRUE). The data to be reloaded (i.e. the one you pass to dataTableAjax()) must have exactly the same number of columns as the previous data object in the table.


DT documentation built on Oct. 5, 2023, 5:09 p.m.