0
に基づいにtextInput行を削除し、私は私のスクリプトを変更:シャイニー:動的に追加/ <a href="https://gallery.shinyapps.io/111-insert-ui/" rel="nofollow noreferrer">this article</a>に基づいてインデックス
library(shiny)
ui = fluidPage(
actionButton("add", "Add new Row", icon=icon("plus", class=NULL, lib="font-awesome")),
actionButton("remove", "Remove last Row", icon=icon("times", class = NULL, lib = "font-awesome")),
tags$div(id = 'placeholder')
)
server = function(input, output) {
## keep track of elements inserted and not yet removed
inserted <- c()
observeEvent(input$add, {
id <- ''
insertUI(
selector = "#placeholder",
where = "beforeBegin",
ui =tags$div(
id = id,
fluidRow(
column(2,
textInput("alias", label = h5("first"))
),
column(2,
textInput("pop", label = h5("second"))
),
column(2,
textInput("parent", label = h5("third"))
),
column(2,
textInput("dims", label = h5("fifth"))
),
column(2,
textInput("method", label = h5("fourth"))
),
column(2,
textInput("args", label = h5("sixth"))
)
)
)
)
inserted <<- c(inserted, id)
})
observeEvent(input$remove, {
removeUI(
## pass in appropriate div id
selector = paste0('#', inserted[length(inserted)])
)
inserted <<- inserted[-length(inserted)]
})
}
shinyApp(ui = ui, server = server)
私はthis questionに見えたが、add
ボタンが正常に動作しますが、行が行うbefore.Theよりも混乱していますremove
ボタンを押すと消えません。私は間違って何をしていますか?
ありがとうございます!
:
は以下の適応コードを参照してください? – Rivka新しい質問、...;)真剣に、私は同様にreactValueにdata.tableを格納し、そこに更新します。あなたがそこに助けを必要とするならば、私は新しい質問でそれをしなければならないと思うし、あなたはここに私に通知することができます... – BigDataScientist
解決済み@BigDataScientist – Rivka