将闪亮的DT行复制到用户剪贴板 [英] Copy a Shiny DT row to users clipboard

查看:66
本文介绍了将闪亮的DT行复制到用户剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以使用户将闪亮的数据表(DT)中的选定行复制(Ctrl + C)到剪贴板.理想情况下,它还将提供数据表的列名或标题.

Is there a way to have the selected row(s) in a shiny datatable (DT) be available for the user to copy (Ctrl+C) to their clipboard. Ideally it would also supply the data table's column names or headers.

global.R

library(rclipboard)
library(shiny)

ui.R:

...
rclipboardSetup(),
...
uiOutput("copy"),

server.R:

output$copy = renderUI({
    s = input$orders_rows_selected
    rclipButton("copybtm","Copy",data()[s,],icon("clipboard"))
  })

推荐答案

以下是如何获取按钮以复制所选行的方法.还有列标题.

Here is how to get a button to copy the selected rows. And there are the column headers too.

datatable(
  iris, 
  rownames = FALSE,
  extensions = c("Buttons", "Select"),
  options = 
    list(
      select = TRUE,
      dom = "Bfrtip",
      buttons = list(
        list(
          extend = "copy",
          text = 'Copy',
          exportOptions = list(modifier = list(selected = TRUE))
        )
      )
    )
)

这篇关于将闪亮的DT行复制到用户剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆