Skip to content

Commit

Permalink
Add support for list of classes in DT2BSClass() (#1089)
Browse files Browse the repository at this point in the history
Co-authored-by: Yihui Xie <[email protected]>
  • Loading branch information
pedropark99 and yihui authored Oct 4, 2023
1 parent faba4fb commit 65e6169
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

- Fixed a bug that when using `updateSearch()`, the clear button inside the input box doesn't show up, and the table doesn't update when the input is cleared (thanks, @DavidBlairs, #1082).

- Added support for a list of Booleans as input to the `class` argument of `DT::datatable()` when `style = 'bootstrap'` (thanks, @pedropark99, #1089). In other words, you can now select the Bootstrap classes you want to use at `DT::datatable()` by using a list of Booleans that select the classes you want to use. In the example below, we are producing an HTML table that uses the `stripe` and `hover` Bootstrap classes:

```r
DT::datatable(mtcars, class = list(stripe = TRUE, compact = FALSE, hover = TRUE), style = "bootstrap")
```

- Handle `NULL` return from `bslib::theme_version()` (thanks, @slodge-work, #1090).

# CHANGES IN DT VERSION 0.29
Expand Down
6 changes: 5 additions & 1 deletion R/datatables.R
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,11 @@ DTDependencies = function(style) {

# translate DataTables classes to Bootstrap table classes
DT2BSClass = function(class) {
class = unlist(strsplit(class, '\\s+'))
class = if (is.list(class)) {
names(which(unlist(class)))
} else {
unlist(strsplit(class, '\\s+'))
}
if ('display' %in% class)
class = unique(c('stripe', 'hover', 'row-border', 'order-column', class))
BSclass = c(
Expand Down

0 comments on commit 65e6169

Please sign in to comment.