【发布时间】:2017-10-12 16:02:03
【问题描述】:
我想在闪亮的 DT 表中插入一个超链接。
为了节省加载时间,我想插入指向当前视图的超链接 (input$table_rows_current)。
我已经厌倦了观察,但我不知道如何指定插入超链接的位置以及如何?
非常感谢任何帮助。
这里是示例代码:
library(shiny)
createLink <- function(val) {
sprintf('<a href="https://www.google.com/#q=%s" target="_blank" >%s</a>',val,val)
}
ui <- fluidPage(
titlePanel("Table with Links!"),
sidebarLayout(
sidebarPanel(
h4("Click the link in the table to see
a google search for the car.")
),
mainPanel(
dataTableOutput('table1')
)
)
)
server <- function(input, output) {
output$table1 <- renderDataTable({
dt <- datatable(mtcars, escape=FALSE, selection = 'none') %>% formatStyle(0, cursor = 'pointer')
})
observe({
List <- input$table1_rows_current
List <- createLink(List)
return(List)
})
}
shinyApp(ui, server)
【问题讨论】:
-
我有不同的问题......这只是一个例子。我有非常大的数据矩阵,如果我使用这段代码,加载需要 15-20 分钟......所以为了节省时间,我只想在表格中的当前视图中添加超链接。