我正在使用renderUI在我的UI上创建动态文本框和下拉列表。我希望捕获textbox / dropdown中的更改事件并修改数据框
下面是创建UI的代码
server <- function(input, output, session){
output$fileContent <- renderTable({
inFile <- input$csvFile
csvContent <- read.csv(inFile$datapath)
output$summary <- renderPrint({str(csvContent)})
allColumns <- names(csvContent)
types <- sapply(csvContent, class)
w <- ""
for (i in 1:length(allColumns)){
w <- paste(w, selectInput(paste("inp",allColumns[i], sep = "_"), allColumns[i],choices = c("factor","integer","logical","character", "Date"), selected = types[i], width = 200))
}
output$columns <- renderUI({ HTML(w) })
return (head(csvContent))
})所需输出-
上面的代码在UI上根据需要呈现文本框,但没有在文本框中的值更改时捕获事件。由于控件是动态的,我不能为静态捕获事件编写代码,因为控件名称将动态生成
发布于 2019-02-06 09:55:13
在https://gist.github.com/mine-cetinkaya-rundel/0fe2a9830f7151e72053239e73350592上得到了答案
它有一个样例应用程序,可以很好地处理动态UI
https://stackoverflow.com/questions/54543015
复制相似问题