r - 调整 Html 表格大小以适应屏幕 RSHINY
问题描述
如何调整 HTML 表格的大小以适应计算机的屏幕?这就是我闪亮的应用程序目前的外观,我尝试使用流畅的行列,但它没有给我正确的结果。我想我在这里遗漏了一些东西。
这是我闪亮的服务器和用户界面
用户界面
library("shiny")
library(daff)
library(dplyr)
library(shinythemes)
setwd("PATH")
ui <- fluidPage(theme = shinytheme("cerulean"),
fluidPage(
titlePanel("Automated Data Dictionary Comparison"),
sidebarLayout(
sidebarPanel(
selectInput(inputId = 'Dic1',
label = 'Choose First Data Dictionary:',
choices = list.files(path = "./data",
full.names = FALSE,
recursive = FALSE)),
selectInput(inputId = 'Dic2',
label = 'Choose Second Data Dictionary:',
choices = list.files(path = "./data",
full.names = FALSE,
recursive = FALSE))
),
mainPanel(
uiOutput('contents'))
)
)
)
Html 表在输出部分。服务器.R
library(shiny)
library(dplyr)
library(daff)
library(shinythemes)
setwd("PATH")
server <- function(input, output) {
# Parse first file
dataset1 <- reactive({
infile <- input$Dic1
if (is.null(infile)){
return(NULL)
}
x <- read.csv(paste0("./data/", infile[[1]]))
x
})
# Parse second file
dataset2 <- reactive({
infile <- input$Dic2
if (is.null(infile)){
return(NULL)
}
x <- read.csv(paste0("./data/", infile[[1]]))
x
})
# Create comparison table (reactive as both of its elements are reactive)
diff <- reactive({
x <- render_diff(diff_data(data_ref=dataset1(), data=dataset2()),use.DataTables=TRUE)
x
})
#Output
output$contents <- renderUI({
HTML(diff())
})
}
预期的结果是我的表格可以在屏幕上完全看到而不是扩展我必须滚动才能在屏幕外看到整个表格
解决方案
试试用这个
mainPanel(
HTML("<div style ='overflow:auto; ' >"),
uiOutput('contents'),
HTML("</div>")
)
或尝试设置height
或width
使用 css设置
mainPanel(
HTML("<div style ='overflow:auto; height:500px ' >"),
uiOutput('contents'),
HTML("</div>")
)
推荐阅读
- docker - Gitlab - 尝试在docker中部署时管道总是失败
- c++ - 我无法将几何点的值分配给变量
- debugging - 使用核心转储日志跟踪问题
- plsql - 如何选择某些选定行的 max() 值?
- python - 如何获得 α-碳的相邻氢原子列表?
- flutter - FlutterSummerNote 的 getText() 方法在第一次单击按钮时返回空白
- python - Python:如何选择可被两个数字整除的特定数字,但仅打印所选数字?
- python - 如何使用python在字典中创建列表
- javascript - 相当于 jquery 中的 document.createElement
- java - 使用 PDFBox 合并 PDF 文档时出错