首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >显示弹出模态对话框/popup在闪亮的仪表板上单击行

显示弹出模态对话框/popup在闪亮的仪表板上单击行
EN

Stack Overflow用户
提问于 2017-08-14 11:53:08
回答 1查看 2.2K关注 0票数 1

我有一个数据表,它正在使用DT:: rendertableOutput在我闪亮的仪表板上呈现。这些列是ABCD。现在,我只想在打开这个闪亮的应用程序时只显示列AB,然后如果我单击显示的datatable上的特定行,我需要弹出一个弹出,它在列CD中显示同一行的数据。

以下是我的数据框架:

代码语言:javascript
运行
复制
> df
   A         B       C      D
   A1        B1      C1     D1
   A2        B2      C2     D2   

条件:

  1. 在打开这个闪亮的应用程序时,只会显示列AB
  2. 当单击显示数据的row 1时,row 1的列CD将显示为具有close按钮的弹出窗口。在显示其他行时,此操作同样继续。
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-14 13:25:55

让我们尝试将其添加到服务器代码中。本质上,我们触发了一个模态对话框,当您选择一个特定的行时,它会出现,并显示其余的数据。

代码语言:javascript
运行
复制
require(dplyr)

#Here's our table:
tbl <- data.frame(A= c('A1','A2'),
           B= c('B1','B2'),
           C = c('C1','C2'),
           D = c('D1','D2'))

#The dt output code
output$my_table <- renderDataTable({
       datatable(tbl %>% select(A,B),selection='single')
})

#reactive table based on the selected row 
tbl_reactive <- reactive({
       tbl[as.numeric(input$my_table_rows_selected[1]),]
})

#here's the table displayed in our modal
output$modal_table <- renderDataTable({
      tbl_reactive()
})

 #our modal dialog box
    myModal <- function(failed=FALSE){
       modalDialog(
  dataTableOutput('modal_table'),
         easyClose = TRUE

       )
     }

#event to trigger the modal box to appear
 observeEvent(input$my_table_rows_selected,{

   showModal(myModal())

 })
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45673948

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档