css - 如何在 DT::datatable 中禁用 scrollX
问题描述
我有一张我渲染的桌子using DT::datatable
。我想要 Y 滚动但没有 X 滚动,也没有长线的换行。我找到了Scroller
扩展,但我无法禁用 X 滚动。
例子:
---
title: "dt_render"
output: html_document
---
```{r render dt, echo = FALSE, message = FALSE}
library(DT)
DF = data.frame(x = 1:100, y = rep("a really really really really really really really really really really really really really really really really really really really really really really really long line", 100))
datatable(
DF,
extensions = c('Buttons', 'Scroller'),
options = list(
dom = 'Bfrtip',
buttons = c('colvis','csv'),
deferRender = TRUE,
scrollY = 200,
scroller = TRUE,
scrollX = FALSE
),
class = 'display compact nowrap'
)
```
输出:
解决方案
The following solves it.
I am not happy with the width = 1000
that seems bad, is there something better ?
---
title: "dt_render"
output: html_document
css: styles.css
---
```{r render dt, echo = FALSE, message = FALSE}
library(DT)
DF = data.frame(x = 1:100, y = rep("a really really really really really really really really really really really really really really really really really really really really really really really long line", 100))
datatable(
DF,
extensions = c('Buttons', 'Scroller', 'KeyTable'),
width = 1000,
options = list(
dom = 'Bfrtip',
buttons = c('colvis','csv'),
scrollY = 200,
scroller = TRUE,
keys = TRUE
),
class = 'display compact nowrap'
)
```
with in the css file
.dataTables_scrollBody
{
overflow-x:hidden !important;
overflow-y:auto !important;
}
output:
推荐阅读
- python - 在 Python 中与客户端服务器通信作斗争
- javascript - PHP 多页面表单将 PHP 变量转换为不同页面上的 JavaScript
- python - Python - 我如何在玩家不断增加分数时保存他们的分数?任何帮助表示赞赏
- python - Flask - 错误:导入“应用程序”时,引发了 ImportError
- c# - 在 C# 中创建 3D 坐标
- html - Ionic:取消选中所有复选框的按钮
- macos - 在 mac 上编译 openssl 时遇到问题
- swift - 点击两次选项卡时如何转到根选项卡视图?
- python - 如何检查输入是否与字符串相同
- python - 处理 Pandas 中的 OutOfBoundsDatetime 错误