flexdashboard icon indicating copy to clipboard operation
flexdashboard copied to clipboard

autoWidth Rendering Garbled

Open ghost opened this issue 5 years ago • 2 comments

---
title: "autoWidth garbled"
output: flexdashboard::flex_dashboard
---

```{r}
library(tidyverse)
library(DT)
datatable(mtcars %>% as_tibble() %>% select(1:4), 
          options = list(autoWidth = TRUE,
                         columnDefs = list(list(width = '50px', 
                                                targets = "_all"))))
```

The code above is my first attempt at autoWidth within DT and flexdashboard. The code looks correct, yet the output is quite garbled (ie the column headings are not aligned with the column bodies). Tested in Chrome. I imagine IE and Safari won't fare much better. Version Info: [1] DT_0.16 flexdashboard_0.5.2

autowidth not working

ghost avatar Nov 04 '20 21:11 ghost

Does that {DT} code work for you outside of {flexdashboard} (if so, can you also please include a screenshot of the "expected" result?)

cpsievert avatar Mar 30 '21 22:03 cpsievert

I can reproduce this. The key is that the header column should be centered over the table but it moves whenever the window is resized. It appears as expected in an html_document() so there's a chance it's the result of an interaction with flexdashboard's CSS.

image

gadenbuie avatar Feb 28 '23 21:02 gadenbuie