我在一个闪亮的应用程序中有一个 rhandsontable,它有 2 行。它使用 reactiveValues() 在其中加载值。禁止通过拖动单元格来创建其他行
fillHandle = list(direction='vertical', autoInsertRow=FALSE))
应该允许用户通过上下文菜单创建额外的行,但不超过 10 行。我虽然使用 customOpts 来做,用户可以在其中添加新行直到nrow(table) == 10
,但我对 javascript 非常不好。我尝试以不同的方式进行操作(请参见下面的代码),但无法使其工作。另外,有没有办法以另一种方式做到这一点?
这是我到目前为止的代码片段:
output$table <- renderRHandsontable({
rhandsontable(data.frame(rv_values),
fillHandle = list(direction='vertical', autoInsertRow=FALSE)) %>%
hot_context_menu(allowRowEdit = TRUE, allowColEdit = FALSE)
})
我试图allowRowEdit
像这样手动更改,但不太清楚如何使它工作:
observeEvent(input$table, {
if(nrow(hot_to_r(input$table)) > 10)
#magic happens here
})
有任何想法吗?