DT2 loads extensions on demand. Instead of shipping all 15+ extensions to every page, only the CSS/JS for extensions you actually use are included.
There are two ways to specify extensions:
extensions = c("Buttons", "Select") to
dt2()options list and infers which extensions are needed (this
is the default when extensions = NULL)dt2_extensions()
#> name version dir
#> Buttons Buttons 3.2.5 buttons
#> ColReorder ColReorder 2.1.1 colreorder
#> ColumnControl ColumnControl 1.1.0 columncontrol
#> DateTime DateTime 1.6.0 datetime
#> FixedColumns FixedColumns 5.0.5 fixedcolumns
#> FixedHeader FixedHeader 4.0.3 fixedheader
#> KeyTable KeyTable 2.12.1 keytable
#> Responsive Responsive 3.0.6 responsive
#> RowGroup RowGroup 1.6.0 rowgroup
#> RowReorder RowReorder 1.5.0 rowreorder
#> Scroller Scroller 2.4.3 scroller
#> SearchBuilder SearchBuilder 1.8.4 searchbuilder
#> SearchPanes SearchPanes 2.3.5 searchpanes
#> Select Select 3.1.0 select
#> StateRestore StateRestore 1.4.2 staterestoreEnable row selection with the Select extension:
In Shiny, selected rows are available via
input$<id>_state$selected.
DT2 enables the Responsive extension by default. Tables fill 100% width and columns that don’t fit are collapsed into expandable child rows.
To disable for a specific table:
To customise Responsive behaviour (e.g., disable child rows):
ColumnControl adds per-column controls (order indicators, search dropdowns, column visibility) directly in the table header:
dt2(iris, options = list(
pageLength = 8,
columnControl = list("order", "searchDropdown",
list(
list(extend = "orderAsc", text = "Sort Ascending"),
list(extend = "orderDesc", text = "Sort Descending"),
"spacer",
list(extend = "colVisDropdown", text = "Toggle Columns")
)
),
ordering = list(indicators = FALSE, handler = FALSE)
))Keep the header visible while scrolling:
Extensions compose naturally. Here’s Buttons + Select + ColumnControl:
dt2(iris, options = list(
pageLength = 8,
select = list(style = "multi", items = "row"),
layout = list(
topEnd = list(
buttons = list(
list(extend = "selected", text = "Selected Only"),
list(extend = "selectAll", text = "Select All"),
list(extend = "selectNone", text = "Deselect"),
"spacer",
list(extend = "csvHtml5", exportOptions = list(modifier = list(selected = TRUE)))
)
)
),
columnControl = list("order", "searchDropdown"),
ordering = list(indicators = FALSE, handler = FALSE)
))To add a DataTables plugin not yet in the registry:
tools/get-dt2-libs.shR/dt2_extensions.R
(.dt2_extension_registry()).dt2_detect_extensions()R/dt2_check_updates.R
(.dt2_npm_map())bash tools/get-dt2-libs.sh to download the
filesdt2(data, extensions = "YourPlugin")The declarative registry in dt2_extensions.R is the
single source of truth for extension metadata (version, JS files, CSS
files, dependencies).
Check for newer versions of all bundled JS/CSS libraries:
Library Installed Latest Compat. Status
-----------------------------------------------------------------
DataTables 2.3.4 2.3.7 2.3.7 ⚠️ UPDATE
jQuery 3.7.0 4.0.0 3.7.1 🔒 PINNED [pin: 3.x]
Buttons 3.2.5 3.2.6 3.2.6 ⚠️ UPDATE
...
If you are developing DT2 (working from the source tree), apply compatible updates automatically:
dt2_update_libs() # patch files + download new JS/CSS
dt2_update_libs(dry_run = TRUE) # preview without changing anything
dt2_update_libs(download = FALSE) # patch R files only (manual download)Version constraints prevent incompatible upgrades:
Libraries marked as PINNED are up to date within their
allowed range. Edit .dt2_version_constraints() to change
the allowed ranges.