3
我有一個閃亮的應用程序shinyTable。它是可編輯的,但由於應用程序中的其他位置的submitButton,只有按下按鈕後纔會保存編輯。如果進行了多個更改並按下該按鈕,則只保存最後的更改。與shinyTable和submitButton編輯表
我的問題是我怎樣才能保存所有已做的更改? 也許有一種方法可以獲得UI中整個表格的內容,這樣我就可以解決問題了嗎? 或者我會更好使用shinysky或其他東西?
下面是一個基於軟件包示例的可重複的示例。您會看到如果您對上表進行了2次更改,然後只按下按鈕,則第二次更改將被複制到下表中。
library(shiny)
library(shinyTable)
server <- function(input, output, session) {
rv <- reactiveValues(cachedTbl = NULL)
output$tbl <- renderHtable({
if (is.null(input$tbl)){
#fill table with 0
tbl <- matrix(0, nrow=3, ncol=3)
rv$cachedTbl <<- tbl
print(tbl)
return(tbl)
} else{
rv$cachedTbl <<- input$tbl
print(input$tbl)
return(input$tbl)
}
})
output$tblNonEdit <- renderTable({
rv$cachedTbl
})
}
ui <- shinyUI(pageWithSidebar(
headerPanel("Simple Shiny Table!"),
sidebarPanel(
helpText(HTML("A simple editable matrix with an update button.
Shows that only most recent change is saved.
<p>Created using <a href = \"http://github.com/trestletech/shinyTable\">shinyTable</a>."))
),
# Show the simple table
mainPanel(
#editable table
htable("tbl"),
#update button
submitButton("apply table edits"),
#to show saved edits
tableOutput("tblNonEdit")
)
))
shinyApp(ui = ui, server = server)
謝謝你的時間。 Andy
也許你可以使用Actionbutton來代替? – 2014-10-29 17:38:14
謝謝@pops。我確實嘗試了actionButton,但它在我的應用程序中的其他地方搞砸了。 – Andy 2014-10-29 18:50:02