Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderDT() with DT.fillContainer option being set to TRUE #286

Closed
shrektan opened this issue Oct 6, 2020 · 0 comments
Closed

renderDT() with DT.fillContainer option being set to TRUE #286

shrektan opened this issue Oct 6, 2020 · 0 comments

Comments

@shrektan
Copy link

shrektan commented Oct 6, 2020

When using flexdashboard with DT tables, the DT table will be vertically filled automatically, thanks to the following lines :

if (is.na(getOption('DT.fillContainer', NA))) {
options(DT.fillContainer = TRUE)
exit_actions <- c(exit_actions, function() {
options(DT.fillContainer = NULL)
})
}

However, this magic only works for a static DT table, i.e., the table generated by DT::datatable() directly.

If the table is generated by DT::renderDT(), i.e., on the shiny runtime, DT.fillContainer option won't be set to TRUE and the table rendered may be displayed in an undesired style, when the container's height is limited. What's worse is, users can't even view the hidden data rows, since there's no Y-scroller.

It's very confused to the user and it's difficult to know that this can be resolved by providing the fillContainer = TRUE to the DT::datatable() call.

Since FlexDashboard has already does this magic (rendering DT table with DT.fillContainer option being set to TRUE) to the static DT, I'm asking the question that :

  1. Can FlexDashboard render a reactive DT table (shiny runtime) with DT.fillContainer option being set to TRUE, automatically?

  2. If not, is it possible to do it in DT? I mean, is it possible for DT to know that it's rendering within a FlexDashboard?

Thanks!

(Ref to rstudio/DT#818)

An Example to illustrate what I say (See the comment on the sidebar)

---
title: "Test Flexboard Shiny App"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(DT)
```


Sidebar {.sidebar}
-----------------------------------------------------------------------

Please pay attention to the scrollY bar of each table. 

- The 2nd table's scroll bar can't be displayed but the 1st and 3rd can.

- The reason is that DT table need `fillContainer` to be set to `TRUE` in order to display correctly.

- FlexDashboard is able to enable this option for static DT table but not for DT in Shiny mode.



Column Data
-----------------------------------------------------------------------

### 1. shiny - fillContainer = TRUE

```{r}
DT::renderDT(DT::datatable(
  mtcars, fillContainer = TRUE
))
```


### 2. shiny - no fillContainer

```{r}
DT::renderDT(DT::datatable(
  mtcars
))
```

### 3. static - no fillContainer

```{r}
DT::datatable(
  mtcars
)
```

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant