如何在闪亮的应用程序中的 fluidRow 内的框元素中显示悬停

How to display a hover in the box element inside fluidRow in shiny app

我有一个包含多个流体行的代码,每个流体行都包含多个默认折叠的可折叠框元素, 我担心的是当盒子在闪亮的应用程序上折叠时显示悬停,描绘 "you can open the box to see the data and also a small brief about the data present"

借助 BSTooltip 功能,我可以在框内的数据上显示悬停,但不能在可折叠框上显示。

这是一个主要功能。

请帮忙。

fluidRow(
                box(
                  id = "djc",
                  title = "BY SEGMENT",
                  width = 12,
                  status = "primary",
                  solidHeader = TRUE,
                  align='center',
                  collapsible = TRUE,
                  collapsed = TRUE,
                  DT::dataTableOutput("tab_PF2")
                ),
                bsTooltip("djc", "This is a Table which talks about all the segments and there data shift and book shift respectfully", placement = "bottom", trigger = "hover",
                          options = NULL)
              ))

上面是一个流畅的行,我可以在其中描述数据的工具提示。

不确定您的确切用例,但您可以使用 JavaScript 向所有框折叠按钮添加 title 属性。

将此代码添加到您的 ui:

tags$head(tags$script("
  $( document ).ready(function() {
    $('.btn.btn-box-tool').attr('title', 'hovering info');
  });
"))

我能够通过在列而不是列名上应用 js 来解决你的问题。

library(shiny)

shinyApp(
  ui = fluidPage(
    DT::dataTableOutput("mtcarsTable")
  ),
  server = function(input, output) {

    output$mtcarsTable <- DT::renderDataTable({

      DT::datatable(datasets::mtcars[,1:3], 
                    options = list(rowCallback = JS(
                      "function(nRow) {",
                      "var full_text = 'Test1';",
                      "var full_text1 = 'Test2';",
                      "$('td:eq(0)', nRow).attr('title', full_text);",
                      "$('td:eq(1)', nRow).attr('title', full_text1);",
                      "}")
                    )
      )

    })
  }
)

希望对你有所帮助。