Is there any way to get a tooltip for each and every cell in datatable in r shiny? There are so many ways to get the hover row or column. But I could not find a way to get both row and column index and show a different hover tooltip for each and every cell. Can anyone modify the following code?
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(
dataTableOutput('table'),
verbatimTextOutput('hoverIndex'),
),
server = function(server, input, output) {
output$hoverIndex <- renderText({
UI_out <- input$hoverIndexJS
return(paste("hover column info", UI_out))
})
output$table <- renderDataTable({
DT_out <- data.frame(`A` = 1:5, `B` = 11:15, `C` = LETTERS[1:5])
DT_out <- datatable(DT_out
,rownames = F
,callback = JS("
/* code for columns on hover */
table.on('mouseenter', 'td', function() {
var td = $(this);
var col = table.cell( this ).index().columnVisible;
var row = table.cell( this ).index().row;
$('td[row][col]).attr('title', row+col);
Shiny.onInputChange('hoverIndexJS', info_out);
});"
)
)
return(DT_out)
})
}
)