问题
Is there any way to get a hover tool tip working on a shiny data table that has some information, this is possible on graphs but never seen it done before on a data table
回答1:
Yes, like this (no need of Shiny):
library(DT)
datatable(head(iris),
options=list(initComplete = JS(c(
"function(settings){",
" var table = settings.oInstance.api();",
" var cell = table.cell(2,2);",
" cell.node().setAttribute('title', 'TOOLTIP CONTENTS');",
"}")))
)
table.cell(2,2)
means the cell at row 2 and column 2; indices start at 0 in Javascript, and the column of row names is taken into account.
来源:https://stackoverflow.com/questions/53856800/hover-tool-tip-over-datatable-value-in-r