In the dashboardHeader function of shinydashboard, you can add multiple menus, such as a drop down menu of notifications. When a notification is displayed, it is natural for the user to click on a specific notification, so as to get more information or to take some action. I'd like to be able to detect which notificationItem the user has clicked on, and do some things based on that (e.g. update a map, show a table with the data relevant to that notification, etc.).
here's what I hoped would work, but doesn't:
ui.R
dashboardPage(
dashboardHeader(dropdownMenuOutput("dropdownmenu")),
dashboardSidebar(),
dashboardBody(textOutput("notificationoutput"))
)
server.R
server = shinyServer(function(input, output, session){
output$dropdownmenu = renderMenu({
dropdownMenu(type = "notifications", badgeStatus = "warning",
notificationItem(icon = icon("users"), status = "info",
"5 new members joined today"
),
notificationItem(icon = icon("warning"), status = "danger",
"Resource usage near limit."
),
notificationItem(icon = icon("shopping-cart", lib = "glyphicon"),
status = "success", "25 sales made"
),
notificationItem(icon = icon("user", lib = "glyphicon"),
status = "danger", "You changed your username"
)
)
})
output$notificationoutput = renderText({
if(is.null(input$dropdownmenu)){
notificationitemid = "a"
}else{
notificationitemid = input$dropdownmenu
}
return(notificationitemid)
})
})
In my ideal world, something like this would update the "a" to an id or index that I could use to determine which notification had been clicked. Is that possible?