[英]R shiny dashboard tabItems not apparing
Here's my ui.R and server.R. 这是我的ui.R和server.R。 I'm not sure why the headers in dashboardBody don't show up. 我不确定为什么dashboardBody中的标题没有显示。
server.R
shinyServer(function(input, output){
})
ui.R
dashboardPage(
dashboardHeader(title = "Analysis"),
dashboardSidebar(
sidebarMenu(
menuItem("Data Pull", tabName = "dataPull", icon = icon("database"),
dateInput("startDateInput", "What is the starting date?", value = NULL, min = NULL, max = NULL, format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en"),
dateInput("endDateInput", "What is the ending date?", value = NULL, min = NULL, max = NULL, format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en")
),
menuItem("View Data", tabName = "dataView", icon = icon("table"),
selectInput("dataViewSelectionInput", label = "Selection of Interest?", choices = c(1,2,3), multiple = TRUE),
checkboxInput("dataViewAll", label = "View all pulled", value = TRUE)
)
)
),
dashboardBody(
tabItems(
tabItem(tabName = "dataPull",
h1("Data Selected")
),
tabItem(tabName = "dataView",
h2("Viewing Data")
)
)
)
)
Currently, the dashboard seems to disallow switching to a tab and using a dropdown menu, I found a fix for it here: 当前,仪表板似乎不允许切换到选项卡并使用下拉菜单,我在这里找到了针对其的修复程序:
add this function to the beginning of your UI, or your globals: 将此函数添加到您的UI或全局变量的开头:
convertMenuItem <- function(mi,tabName) {
mi$children[[1]]$attribs['data-toggle']="tab"
mi$children[[1]]$attribs['data-value'] = tabName
mi
}
then your ui file becomes: 那么您的ui文件将变为:
ui.R ui.R
dashboardPage(
dashboardHeader(title = "Analysis"),
dashboardSidebar(
sidebarMenu(
convertMenuItem(menuItem("Data Pull", icon = icon("database"),
dateInput("startDateInput", "What is the starting date?", value = NULL, min = NULL, max = NULL, format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en"),
dateInput("endDateInput", "What is the ending date?", value = NULL, min = NULL, max = NULL, format = "yyyy-mm-dd", startview = "month", weekstart = 0, language = "en"),
tabName = "dataPull"),
tabName="dataPull"),
convertMenuItem(menuItem("View Data", icon = icon("table"),
selectInput("dataViewSelectionInput", label = "Selection of Interest?", choices = c(1,2,3), multiple = TRUE),
checkboxInput("dataViewAll", label = "View all pulled", value = TRUE),
tabName = "dataView"),
tabName="dataView")
)
),
dashboardBody(
tabItems(
tabItem(tabName = "dataPull",
h1("Data Selected")
),
tabItem(tabName = "dataView",
h2("Viewing Data")
)
)
)
)
This works because there is some default behavior in menuitem where if the menuItem has subitems, it won't set the data-toggle or data-value tags, so I set them manually. 之所以可行,是因为menuitem中有一些默认行为,如果menuItem具有子项,它将不会设置数据切换或数据值标签,因此我手动设置它们。 (Edited to remove a typo) (编辑以消除错字)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.