我已经使用 rhandsontable 函数创建了一个 table,现在如何更新提交按钮上的 table?
I have created a table using rhandsontable function now how can I update the table on submit button?
ui <- fluidPage(
# Application title
# titlePanel("Old Faithful Geyser Data"),
mainPanel(
rHandsontableOutput('table'),
br(),
submitButton("Apply changes"),
verbatimTextOutput('selected')
)
)
server <- function(input, output) {
data1 = read.csv("SampleCSVFile_2kb.csv", TRUE,",")
output$table = renderRHandsontable(rhandsontable(data1, width = 1000, height = 250))
output$selected=renderPrint({
cat('\nChanged Cell Old Value:',input$table$changes$changes[[1]][[3]])
cat('\nChanged Cell New Value:',input$table$changes$changes[[1]][[4]])
})
}
shinyApp(ui = ui, server = server)
据我所知,当您按下提交按钮时,您想访问您服务器内的 rhandsontable 输入。
在下面的示例中,我修改了您的代码,以便在 tableoutput
.
中显示更新后的 rhandsontable
library(shiny)
library(rhandsontable)
ui <- fluidPage(
# Application title # titlePanel("Old Faithful Geyser Data"),
mainPanel(
rHandsontableOutput('table'),
br(),
submitButton("Apply changes"),
verbatimTextOutput('selected'),
##The updated table output
rHandsontableOutput('tableoutput')
)
)
server <- function(input, output) {
data1 = read.csv("SampleCSVFile_2kb.csv", TRUE,",")
output$table = renderRHandsontable(rhandsontable(data1, width = 1000, height = 250))
output$selected=renderPrint({
cat('\nChanged Cell Old Value:',input$table$changes$changes[[1]][[3]])
cat('\nChanged Cell New Value:',input$table$changes$changes[[1]][[4]])
})
observe(
if(!is.null(input$table)){
output$tableoutput = renderRHandsontable(rhandsontable(hot_to_r(input$table), width = 1000, height = 250))
}
)
}
shinyApp(ui = ui, server = server)
希望对您有所帮助!
ui <- fluidPage(
# Application title
# titlePanel("Old Faithful Geyser Data"),
mainPanel(
rHandsontableOutput('table'),
br(),
submitButton("Apply changes"),
verbatimTextOutput('selected')
)
)
server <- function(input, output) {
data1 = read.csv("SampleCSVFile_2kb.csv", TRUE,",")
output$table = renderRHandsontable(rhandsontable(data1, width = 1000, height = 250))
output$selected=renderPrint({
cat('\nChanged Cell Old Value:',input$table$changes$changes[[1]][[3]])
cat('\nChanged Cell New Value:',input$table$changes$changes[[1]][[4]])
})
}
shinyApp(ui = ui, server = server)
据我所知,当您按下提交按钮时,您想访问您服务器内的 rhandsontable 输入。
在下面的示例中,我修改了您的代码,以便在 tableoutput
.
library(shiny)
library(rhandsontable)
ui <- fluidPage(
# Application title # titlePanel("Old Faithful Geyser Data"),
mainPanel(
rHandsontableOutput('table'),
br(),
submitButton("Apply changes"),
verbatimTextOutput('selected'),
##The updated table output
rHandsontableOutput('tableoutput')
)
)
server <- function(input, output) {
data1 = read.csv("SampleCSVFile_2kb.csv", TRUE,",")
output$table = renderRHandsontable(rhandsontable(data1, width = 1000, height = 250))
output$selected=renderPrint({
cat('\nChanged Cell Old Value:',input$table$changes$changes[[1]][[3]])
cat('\nChanged Cell New Value:',input$table$changes$changes[[1]][[4]])
})
observe(
if(!is.null(input$table)){
output$tableoutput = renderRHandsontable(rhandsontable(hot_to_r(input$table), width = 1000, height = 250))
}
)
}
shinyApp(ui = ui, server = server)
希望对您有所帮助!