闪亮的 DT _row_last_clicked

shiny DT _row_last_clicked

我在使用 rstudio DT 库的闪亮界面中为 table 提供的 _row_last_clicked 选项时遇到问题。我正在尝试 select 数据 table 中的一行,对其进行修改并将其输出到闪亮的 ui.r。它第一次工作 selection,但是当我再次单击我之前刚刚 select 编辑的相同 table 行时,_row_last_clicked 似乎仍然没有响应( =空?)。这是我想要实现的最小示例(ui.r 可能无关紧要):

# server.r-side:

table_x<-# ... loads the dataframe
redo_cal<-reactiveValues()  
redo_cal$a<-1

observe({ 
    redo_cal$a
    output$some_table <- DT::renderDataTable(           
        table_x,
        server = TRUE, # same problem with FALSE
        selection =c('single')
    )
})


observeEvent(
    input$some_table_row_last_clicked,{
    s<-input$some_table_row_last_clicked
    table_x[s,]<- # some reversible modifications based on the row selection ...
    redo_cal$a<-(redo_cal$a+1) # trigger above renderDataTable
})

对于最新的 github 版本的 DT 以及在 CRAN 上找到的版本,该问题仍然存在。我已经阅读了几篇相关文章,但无法找到令人满意的解决方案。非常感谢您的帮助!

如果我没看错你需要some_table_row_selected 并且 table_xdd$d - 在我的例子中)是 reactiveValues

查看示例,其中 # some reversible modifications based on the row selection == log 的 x 每次你 select 这一行中 x 的行值 log-ed

library(shiny)
library(DT)
data=data.frame(x=1:10,y=2:11)

ui=shinyUI(
  fluidPage(
    DT::dataTableOutput("tt")
  )
)


server=shinyServer(function(input, output) {
  dd=reactiveValues(d=data)
  output$tt=DT::renderDataTable(
    datatable(
      dd$d,selection =c('single')
    )
    
    
  )
  observeEvent(input$tt_rows_selected,{
    
    dd$d[input$tt_rows_selected,1]<-log(dd$d[input$tt_rows_selected,1])
  })
})

shinyApp(ui,server)

在每个会话中您的数据都会刷新

PS

最好的最小示例是任何人都可以 copy\paste 和测试的东西。