0

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)
  })
    }
      )
Jaliya
  • 337
  • 5
  • 20
  • 1
    Hi @jaliya, please consider adding a [reproducible example](https://stackoverflow.com/questions/48343080/how-to-convert-a-shiny-app-consisting-of-multiple-files-into-an-easily-shareable) to your question. That will make it easier for others to help. – Florian Feb 19 '18 at 05:58
  • 1
    Possible duplicate of https://stackoverflow.com/questions/40220549/dt-shiny-r-tooltip-and-hide-column – Phil Feb 19 '18 at 07:58
  • I edited my question above with an example code. – Jaliya Feb 19 '18 at 09:52

0 Answers0