How to get the input id on the CommandBar items #199
dawiegriesel
started this conversation in
General
Replies: 1 comment
-
|
Hi @dawiegriesel, You can use library(shiny)
library(shiny.fluent)
library(shiny.router)
ui <- function(id) {
ns <- NS(id)
fluentPage(
actionButton(ns("browser"), "Browser"),
CommandBar(
items = list(
list(
key = "newItem",
text = "New",
iconProps = list(iconName = "Add"),
subMenuProps = list(items = list(
list(
key = "newActivity",
text = "Activity",
iconProps = list(iconName = "AccountActivity"),
onClick = JS("() => Shiny.setInputValue('newActivity', 'click', {priority: 'event'})")
),
list(
key = "newProject",
text = "Project",
iconProps = list(iconName = "NewTeamProject")
)
))
)
)
),
router_ui(
route("activities", (ns("act_1"))),
route("project", (ns("proj_1")))
)
)
}
#' @export
server <- function(id) {
moduleServer(id, function(input, output, session) {
ns <- session$ns
router_server("project")
})
}
shiny::shinyApp(
ui = ui("id"),
server = function(input, output, session) {
server("id")
observeEvent(input$newActivity,{
change_page("activities")
})
}
)Please provide a reproducible example next time. You provided references to some modules that were not supplied in the code chunk. With reprexes it's easier for us to run the code with an issue and answer the question quicker 🙂 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have this rhino app with shiny.router and shiny.fluent. The problem is that I can't call the module as the input value is not available.
`box::use(
shiny[moduleServer, NS, observeEvent, actionButton],
shiny.fluent[fluentPage, CommandBar],
shiny.router[router_ui, router_server, route, change_page],
)
box::use(
app/view/activities,
app/view/project,
)
#' @export
ui <- function(id) {
ns <- NS(id)
fluentPage(
actionButton(ns("browser"), "Browser"),
CommandBar(
items = list(
list(key = "newItem", text = "New", iconProps = list(iconName = "Add"),
subMenuProps = list(
items = list(
list(key = "newActivity", text = "Activity", iconProps = list(iconName = "AccountActivity")),
list(key = "newProject", text = "Project", iconProps = list(iconName = "NewTeamProject"))
)
)
)
)
),
router_ui(
route("activities", activities$ui(ns("act_1"))),
route("project", project$ui(ns("proj_1")))
)
# activities$ui(ns("act_1")),
# project$ui(ns("proj_1"))
)
}
#' @export
server <- function(id) {
moduleServer(id, function(input, output, session) {
ns <- session$ns
router_server("project")
})

}
`
These are the only input items available. I have tried wrapping the key with ns() but also no success.
Please assist with an example to handle this.
Kind regards,
Dawie
Beta Was this translation helpful? Give feedback.
All reactions