get中的错误:对象输入$ table_cell_clicked找不到

发布于 2025-02-12 05:16:11 字数 579 浏览 0 评论 0原文

我想在我的一个数据台上观察Cell_Clicked事件。 通常,我会这样做:

shiny::observeEvent(input$tableId_cell_clicked),{
  ...
}

我现在使用的桌子上有一个存储在变量中的表格。我正在尝试以下操作:

shiny::observeEvent(get(paste0("input$", self$name, "_cell_clicked")), {
  ...
}

这给我带来了以下错误:

Error in get: object 'input$Macrolaag_cell_clicked' not found

创建这样的创作是这样的:

#server side
output[[self$name]] <- DT::renderDataTable( ... )

#ui side
shiny::column(12, DT::dataTableOutput(self$name))

我不明白为什么要遇到此错误。谁能帮我吗?

I want to observe the cell_clicked event on one of my datatables.
Normally I'd do it like this:

shiny::observeEvent(input$tableId_cell_clicked),{
  ...
}

The table I'm using now has a tableId that's stored in a variable. I'm trying the following:

shiny::observeEvent(get(paste0("input
quot;, self$name, "_cell_clicked")), {
  ...
}

This gives me the following error:

Error in get: object 'input$Macrolaag_cell_clicked' not found

The creation happens like this:

#server side
output[[self$name]] <- DT::renderDataTable( ... )

#ui side
shiny::column(12, DT::dataTableOutput(self$name))

I don't understand why I'm getting this error. Can anyone help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄凉少年不暖心 2025-02-19 05:16:12

一个完全有效的例子:

library(DT)
library(shiny)
library(datasets)

ui <- fluidPage(
  DTOutput("iris_out")
)

server <- function(input, output, session) {
  output$iris_out<- renderDT({iris})
  
  table_name <- "iris_out"
  
  shiny::observeEvent({input[[paste0(table_name, "_cell_clicked")]]}, {
    clicked_input_id <- paste0(table_name, "_cell_clicked")
    # input[[clicked_input_id]] is the same as input$iris_out_cell_clicked
    cat("input_id:", clicked_input_id, "\n")
    print(input[[clicked_input_id]])
    })
}

shinyApp(ui, server)

A fully working example:

library(DT)
library(shiny)
library(datasets)

ui <- fluidPage(
  DTOutput("iris_out")
)

server <- function(input, output, session) {
  output$iris_out<- renderDT({iris})
  
  table_name <- "iris_out"
  
  shiny::observeEvent({input[[paste0(table_name, "_cell_clicked")]]}, {
    clicked_input_id <- paste0(table_name, "_cell_clicked")
    # input[[clicked_input_id]] is the same as input$iris_out_cell_clicked
    cat("input_id:", clicked_input_id, "\n")
    print(input[[clicked_input_id]])
    })
}

shinyApp(ui, server)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文