\n","author":{"@type":"Person","name":"YBS"},"upvoteCount":1}}}
Reputation: 547
I am trying to integrate a button to edit a dataframe through my shiny app, but the button stays unresponsive and I don't know why. I've tried accessing it with input$'buttonModifyCountryList'
, input$'Control-buttonModifyCountryList'
and god knows what else but it won't do what I want. What am I missing?
require(shiny)
require(shinyjs)
require(shinydashboard)
require(shinydashboardPlus)
countrySelection <- c("AUSTRIA" = "AT", "HUNGARY" = "HU", "GERMANY" = "DE")
moduleControlUI <- function(id, ...) {
ns <- NS(id)
tabsetPanel(
# Account Receivables
tabPanel(
title = "Settings: Account Receivables",
br(),
fluidRow(
boxPlus(
selectInput(
inputId = ns("countries"),
label = "Countries:",
choices = countrySelection,
selected = countrySelection,
multiple = T
),
actionButton(ns("buttonModifyCountryList"), "Modify Country List"),
width = 4
)
)
)
)
}
moduleControlServer <- function(id) {
moduleServer(
id,
function(input, output, session) {
observeEvent(input$'Control-buttonModifyCountryList', {
browser()
countrySelection <<- edit(countrySelection)
})
}
)
}
ui.r
header <- dashboardHeader(title = "test")
### Sidebar
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Control", tabName = "control", icon = icon("dashboard"))
)
)
### Body
body <- dashboardBody(
tabItems(
# Control tab content
tabItem(tabName = "control",
moduleControlUI("Control")
)
)
)
## put UI together --------------------
ui <- dashboardPage(header, sidebar, body)
server.R
server <- function(input, output, session) {
moduleControlServer("controlD")
}
Upvotes: 0
Views: 61
Reputation: 21349
I am not sure if the expected behavior is to display a pop-up window in Notepad as shown below. Try this
require(shiny)
require(shinyjs)
require(shinydashboard)
require(shinydashboardPlus)
countrySelection <- c("AUSTRIA" = "AT", "HUNGARY" = "HU", "GERMANY" = "DE")
moduleControlUI <- function(id, ...) {
ns <- NS(id)
tabsetPanel(
# Account Receivables
tabPanel(
title = "Settings: Account Receivables",
br(),
fluidRow(
boxPlus(
selectInput(
inputId = ns("countries"),
label = "Countries:",
choices = countrySelection,
selected = countrySelection,
multiple = T
),
actionButton(ns("buttonModifyCountryList"), "Modify Country List"),
width = 4
)
)
)
)
}
moduleControlServer <- function(id) {
moduleServer(
id,
function(input, output, session) {
observeEvent(input[["buttonModifyCountryList"]], {
#browser()
countrySelection <<- edit(countrySelection)
})
}
)
}
## ui.r
header <- dashboardHeader(title = "test")
### Sidebar
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Control", tabName = "control", icon = icon("dashboard"))
)
)
### Body
body <- dashboardBody(
tabItems(
# Control tab content
tabItem(tabName = "control",
moduleControlUI("Control")
)
)
)
## put UI together --------------------
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output, session) {
moduleControlServer("Control")
}
shinyApp(ui, server)
Upvotes: 1