私はボタンがとを押され、変数の条件が満たされた場合のみ、BSのモーダルを表示する必要があります。ブートストラップモーダル複数の条件Rシャイニー
これは、課題が何であるかを示す簡単なアプリです。 num_rows >= 500
と送信ボタンが起動したときだけでなく、送信ボタンが押されたときにBSモーダルを表示する必要があります。
私はこれが条件の一つとしてinput.slider
を使用してconditionalPanel
で行うことができる承知していますが、私の実際のプロジェクトでは、それははるかに複雑これ以上あり、かつBSモーダル/条件付きパネルは(ボタンの両方に依存する必要がありますユーザー入力)とserver
に割り当てられた変数です。
library(shiny)
library(shinyBS)
data = matrix(rnorm(1000*10, 0, 1), nrow = 1000)
ui <- fluidPage(
fluidRow(
column(width = 4,
sliderInput("slider", "Choose Number of Rows to Display", 0, 1000, value = NULL),
submitButton('Submit'),
bsModal("modalExample", "Yes/No", "submit", size = "small", wellPanel(
p(div(HTML("<strong>Warning: </strong> you have chosen to display a large
number of rows. Are you sure you want to proceed?"))),
actionButton("no_button", "Yes"),
actionButton("yes_button", "No")
))
),
column(width = 8,
tableOutput('data')
)
)
)
server <- shinyServer(function(input, output, server){
observe({
num_rows <- input$slider
if(num_rows >= 500){
#
# ACTIVATE MODAL PANEL
#
observeEvent(input$no_button, {
# Do not show table
})
observeEvent(input$yes_button, {
output$table <- renderTable(data)
})
} else{ # Display table normally if number of rows is less than 500
output$table <- renderTable(data)
}
})
})
shinyApp(ui, server)
をその、plsは共有のための解決策を見つけた場合はこれがサイドコメントです:2016年10月& 'modalDialog'と' showModal'のような光沢のある0.14、光沢のある申し出機能するので。私がここに投稿した例を見てくださいhttp://stackoverflow.com/questions/43408022/fileinput-button-with-selectinput-in-shiny。あなたのようにshinyBSライブラリを使っても大丈夫ですが、私は個人的には光っているネイティブ関数を使うのがアプリにとって安全だと考えています。 – Enzo