ToolTip只有一个标题名称的Shiny renderDataTable

时间:2016-11-08 11:22:53

标签: r shiny tooltip

我在Shiny中有一个表格,并希望为列#34; Species"添加只有一个工具提示,即其他列不应该有工具提示。

我设法为所有这些添加了工具提示,但我不知道如何设置特定列的内容。

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(); 

                                     }")))
                          }
    )

1 个答案:

答案 0 :(得分:2)

我修改了你的代码,只获取第4列名称的工具提示,即“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(); 

  }")))

    }
      )

希望这有帮助!