Rainer
Rainer

Reputation: 8681

Embedded DT::datatable() is scrollable when viewed via "Infinite Moon Reader" but not in browser

When I knit and view the example below using Infinite Moon Reader in RStudio, I get a scrollable datatable, but when I view the same file in a browser (safari, chrome, firefox) the datatable is not scrollable. The same (not scrollable) do I get when I knit the example "manually" via CTRL-CMD-K (internal and external viewer the same).

Am I missing something, or is this a bug? Do I have to use the RStudio GUI to give that presentation?

Somehow I have the feeling, that the browser does not ind the java library from datatable and the server which is used by Infinite Moon Reader does?

Also, the tables are presented differently:

Infinite Moon Reader:

enter image description here

In the browser:

enter image description here

The example is as followed:

---
title: "Only Scrolls when using Infinite moon reader"
subtitle: "When opening html or connecting to 127.0.0.1 it does not scroll<br/><html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html>"
author: "Rainer M Krug"
date: "`r Sys.Date()`"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      beforeInit:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
      navigation:
        scroll: false
        click: false
        touch: false
---

```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
library(magrittr)
library(DT)
library(xaringan)
```

```{r echo=FALSE}
data.frame(
  a = 1:100, b = 1:100, c = 1:100, f = 1:100
) %>%
  datatable(
    options = list(
      pageLength = 200,
      dom = "ti",
      ordering = FALSE
    ),
    height = 600
  )
```

---

```{r, echo = FALSE}
sessionInfo()
```

Upvotes: 2

Views: 495

Answers (1)

Ashirwad
Ashirwad

Reputation: 2040

Here's one solution that works:

data.frame(
  a = 1:100, b = 1:100, c = 1:100, f = 1:100
) %>%
  datatable(
    options = list(
      scrollY = 600,
      pageLength = 200,
      dom = "ti",
      ordering = FALSE
    )
  )

This is how the slide will appear when you open it in any browser:

enter image description here

Upvotes: 1

Related Questions