我有一个闪亮的应用程序,用于显示数据表(使用DTedit R pckg),我想:
1)将所有超链接插入同一单元格,并用新行分隔
2)在其他标签中打开超链接。
对于第2点,我尝试了不同版本的'target =“ _ blank”,但它不起作用。我的猜测是我在引用中做错了。
#E.g.:
<a href=' + data + ' target='_blank'>' + 'PanelApp' + '</a>' ;}"
我也尝试过使用双引号(target =“ _ blank”),但是无法识别双引号(我在JS中的经验为零)
这是该应用程序的示例:
library(shiny)
library(DT)
#devtools::install_github('jbryer/DTedit')
library(DTedit)
ui = fluidPage(
h3("How can I have all the links in one column separated by <br> ?"),
mainPanel(
shiny::uiOutput("mytable")
)
)
server = function(input, output){
#dataframe
mydata <- data.frame(Gene = c("GBE1", "KMT2D"),
Metric = c(10, 20))
## Add hyperlinks
mydata$Decipher <- paste0("https://decipher.sanger.ac.uk/gene/", mydata$Gene, "#overview/protein-info")
mydata$PanelApp <- paste0("https://panelapp.genomicsengland.co.uk/panels/entities/", mydata$Gene)
#render table
DTedit::dtedit(input, output,
name = 'mytable',
thedata = mydata,
datatable.options = list(
columnDefs = list(
list(targets= 2,
render = JS("function(data){return '<a href=' + data + '>' + 'PanelApp' + '</a>' ;}")),
list(targets= 3,
render = JS("function(data){return '<a href=' + data + '>' + 'Decipher' + '</a>' ;}"))
)
)
)
}
shinyApp(ui = ui, server = server, options = list(height = 1080))
有人可以在这里说些什么吗?
谢谢!