2016-11-08 42 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(); 

    }"))) 

    } 
    ) 

希望這會有所幫助!