Learn R Programming

linkeR (version 0.1.2)

register_dt: Register a DT DataTable Component

Description

register_dt registers a DT datatable for linking with other components.

Usage

register_dt(
  session,
  registry,
  dt_output_id,
  data_reactive,
  shared_id_column,
  click_handler = NULL
)

Value

NULL (invisible). This function is called for its side effects of registering the component.

Arguments

session

'shiny' session object. The session from the module where the DT is used. This could be global session in non-modular apps.

registry

A link registry created by create_link_registry()

dt_output_id

Character string: the outputId of your DT::DTOutput

data_reactive

Reactive expression returning the data frame for the table

shared_id_column

Character string: name of the ID column

click_handler

Optional function: custom click handler for row selection, must have args (map_proxy, selected_data, session), overrides all default behavior

Examples

Run this code
# \donttest{
  # Create a mock session for the example
  session <- shiny::MockShinySession$new()

  # Create a registry
  registry <- create_link_registry(session)

  # Sample reactive data
  my_data <- shiny::reactive({
    data.frame(
      id = 1:5,
      name = c("A", "B", "C", "D", "E"),
      value = 11:15
    )
  })

  # Register a DT component
  register_dt(session, registry, "my_table", my_data, "id")

  # Verify registration
  print(registry$get_components())
# }

Run the code above in your browser using DataLab