在 flexdashboard 中向侧边栏添加滚动条
Adding scroll to sidebar in flexdashboard
我正在使用 Flexdashboard 设计一个 UI,一些文本输入框超出了常规浏览器 window,我在我的代码中添加了一行 vertical_layout: scroll
但我猜测还不够?所以我的问题是如何启用垂直滚动功能,如下图所示。 ?非常感谢任何提示或指示。
下面是我的代码
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
smooth_scroll: true
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
```
Inputs {.sidebar}
-----------------------------------------------------------------------
```{r}
library(shiny)
library(shinyjs)
shinyjs::useShinyjs()
#tags$hr(),
shinyjs::disabled(textInput("id", "Id", "0"))
textInput("X1", "X1", "")
textInput("X2", "X2", "")
textInput("X3", "X3", "")
textInput("X4", "X4", "")
textInput("X5", "X5", "")
textInput("X6", "X6", "")
textInput("X7", "X7", "")
textInput("X8", "X8", "")
textInput("X9", "X9", "")
textInput("X10", "X10", "")
textInput("X11", "X11", "")
textInput("X12", "X12", "")
textInput("X13", "X13", "")
textInput("X14", "X14", "")
textInput("X15", "X15", "")
textInput("X16", "X16", "")
checkboxInput("X17", "X17", FALSE)
#action buttons
actionButton("submit", "Submit Changes")
```
此问题已在此处解决:https://github.com/rstudio/flexdashboard/issues/27
您可以通过安装来自 GitHub:
的最新版本来使用带有修复程序的版本
devtools::install_github("rstudio/flexdashboard")
或者,您可以将 CSS 的这段代码添加到您的信息中心:
<style type="text/css"> .sidebar { overflow: auto; } </style>
我最近遇到了这个问题,但尝试了上面的 CSS 解决方案,但没有用。我在 DT
数据表中显示我的数据,所以我发现这个解决方案 scrollX
和 scrollY
在当前 Chrome、Firefox 和 IE 上运行良好:
library(DT)
DT::renderDataTable({
datatable(display.data(), style='bootstrap',
class='table-condensed',
editable=TRUE, rownames=FALSE, extensions = 'Buttons',
options = list(
scrollX = '400px', scrollY='360px',
searchHighlight = TRUE,
columnDefs = list(list(width='50px',targets=c(0:9))),
order=list(0, 'asc'),
pageLength=10
)
)
我正在使用 Flexdashboard 设计一个 UI,一些文本输入框超出了常规浏览器 window,我在我的代码中添加了一行 vertical_layout: scroll
但我猜测还不够?所以我的问题是如何启用垂直滚动功能,如下图所示。 ?非常感谢任何提示或指示。
下面是我的代码
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
smooth_scroll: true
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
```
Inputs {.sidebar}
-----------------------------------------------------------------------
```{r}
library(shiny)
library(shinyjs)
shinyjs::useShinyjs()
#tags$hr(),
shinyjs::disabled(textInput("id", "Id", "0"))
textInput("X1", "X1", "")
textInput("X2", "X2", "")
textInput("X3", "X3", "")
textInput("X4", "X4", "")
textInput("X5", "X5", "")
textInput("X6", "X6", "")
textInput("X7", "X7", "")
textInput("X8", "X8", "")
textInput("X9", "X9", "")
textInput("X10", "X10", "")
textInput("X11", "X11", "")
textInput("X12", "X12", "")
textInput("X13", "X13", "")
textInput("X14", "X14", "")
textInput("X15", "X15", "")
textInput("X16", "X16", "")
checkboxInput("X17", "X17", FALSE)
#action buttons
actionButton("submit", "Submit Changes")
```
此问题已在此处解决:https://github.com/rstudio/flexdashboard/issues/27
您可以通过安装来自 GitHub:
的最新版本来使用带有修复程序的版本devtools::install_github("rstudio/flexdashboard")
或者,您可以将 CSS 的这段代码添加到您的信息中心:
<style type="text/css"> .sidebar { overflow: auto; } </style>
我最近遇到了这个问题,但尝试了上面的 CSS 解决方案,但没有用。我在 DT
数据表中显示我的数据,所以我发现这个解决方案 scrollX
和 scrollY
在当前 Chrome、Firefox 和 IE 上运行良好:
library(DT)
DT::renderDataTable({
datatable(display.data(), style='bootstrap',
class='table-condensed',
editable=TRUE, rownames=FALSE, extensions = 'Buttons',
options = list(
scrollX = '400px', scrollY='360px',
searchHighlight = TRUE,
columnDefs = list(list(width='50px',targets=c(0:9))),
order=list(0, 'asc'),
pageLength=10
)
)