是否可以将shinydashboardPlus
中的左侧和右侧边栏固定为永久打开,并禁用隐藏它们的功能?
我已经看到了使用JS或CSS来have them open on startup的一些方法,但是并没有保持永久打开。
library(shiny)
library(shinydashboard)
shinyApp(
ui = dashboardPagePlus(
header = dashboardHeaderPlus(
enable_rightsidebar = TRUE,
rightSidebarIcon = "gears"
),
sidebar = dashboardSidebar(),
body = dashboardBody(),
rightsidebar = rightSidebar(
background = "dark",
rightSidebarTabContent(
id = 1,
title = "Tab 1",
icon = "desktop",
active = TRUE,
sliderInput(
"obs",
"Number of observations:",
min = 0, max = 1000, value = 500
)
)
),
title = "Right Sidebar"
),
server = function(input, output) { }
)
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats4 parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyjs_1.1 shinydashboardPlus_0.7.5 shinydashboard_0.7.1 shinyWidgets_0.5.3
[5] dendextend_1.13.4 tidyr_1.1.0 patchwork_1.0.1 ggplot2_3.3.1
[9] shinyhelper_0.3.2 colorspace_1.4-1 colourpicker_1.0 shinythemes_1.1.2
[13] DT_0.13 shiny_1.4.0.2 dplyr_1.0.0 MSnbase_2.14.2
[17] ProtGenerics_1.20.0 S4Vectors_0.26.1 mzR_2.22.0 Rcpp_1.0.4.6
[21] Biobase_2.48.0 BiocGenerics_0.34.0
答案 0 :(得分:1)
强制rightSidebar
在启动时打开后,隐藏切换按钮使其保持打开状态就足够了:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
ui = tags$body(class="skin-blue sidebar-mini control-sidebar-open", dashboardPagePlus(
header = dashboardHeaderPlus(
enable_rightsidebar = TRUE,
rightSidebarIcon = "gears"
),
sidebar = dashboardSidebar(),
body = dashboardBody(
tags$script(HTML(
'$("body > div > header > nav > div:nth-child(4) > ul > li > a").hide();
document.getElementsByClassName("sidebar-toggle")[0].style.visibility = "hidden";'
)),
),
rightsidebar = rightSidebar(
background = "dark",
rightSidebarTabContent(
id = 1,
title = "Tab 1",
icon = "desktop",
active = TRUE,
sliderInput(
"obs",
"Number of observations:",
min = 0, max = 1000, value = 500
)
)
),
title = "Right Sidebar"
)),
server = function(input, output) {}
)
以下是您可以使用Google chrome复制元素的选择器的方法(右键单击后检查):
Here,您可以找到一个相关的问题(隐藏在服务器端的元素)。