2016-11-08 39 views
0

我有这张闪亮的表并希望只为列名“Species”添加一个工具提示,即其他列不应该有工具提示。我已经为所有人添加了工具提示,但不知道如何设置特定列的内容。工具提示仅适用于一个列名的闪亮renderDataTable

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

            }"))) 

          } 
    ) 

回答

0

我已经修改了您的代码,以获得只有第4列名称即“物种”的工具提示。

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

    }"))) 

    } 
    ) 

希望这会有所帮助!