Reputation: 87
I have a table in Shiny and want to add only one tooltip for the column "Species", i.e. the other columns should not have a tooltip.
I managed to add a tooltip for all of them, but don't know how I can set the content for specific columns.
shinyApp(
ui = fluidPage(
fluidRow(
column(12,
dataTableOutput('table')
)
)
),
server = function(input, output) {
output$table <- renderDataTable(iris, options = list(
pageLength = 5,
initComplete = I("function(settings, json) {
$('th').each( function(){this.setAttribute( 'title', 'TEST' );});
$('th').tooltip();
}")))
}
)
Upvotes: 0
Views: 487
Reputation: 7694
I have modified your code to get the tooltip for only the 4th column name ie "Species".
library(shiny)
shinyApp(
ui = fluidPage(
fluidRow(
column(12,
dataTableOutput('table')
)
)
),
server = function(input, output) {
output$table <- renderDataTable(iris, options = list(
pageLength = 5,
initComplete = I("function(settings, json) {
$('th:eq(4)').each( function(){this.setAttribute( 'title', 'TEST' );});
$('th').tooltip();
}")))
}
)
Hope this helps!
Upvotes: 2