我正在尝试禁用某些列,以使用户无法更改值。然后,我要保存输入并将其写入xlsx。
https://yihui.shinyapps.io/DT-edit/
我尝试使用链接中的示例。
#Import data
iris
render_dt = function(data, editable = 'cell', server = TRUE) {
renderDT(data, selection = 'none', server = server, editable = editable)
}
#Dashboard
header = dashboardHeader()
sidebar = dashboardSidebar()
body = dashboardBody(fluidRow(
DTOutput("test")
)
)
ui = dashboardPage(skin = "yellow", header, sidebar, body)
server = function(input, output, session) {
output$test = render_dt(iris, list(target = "row", disable = list (columns = c(2, 3, 4))))
observeEvent(input$test_cell_edit, {
iris <<- editData(iris, input$test_cell_edit, 'test')
})
observeEvent(session$isClosed()==T,{
isolate(write.xlsx(iris, file = "test.xlsx"))
})
}
shinyApp(ui, server)
我期望第2、3和4列将被锁定,并且我可以编辑其他列。但是所有列都是可编辑的。