ebailey78 / shinyBS

Twitter Bootstrap Components for Shiny
182 stars 47 forks source link

tooltips for table cells #1

Closed bergsmat closed 10 years ago

bergsmat commented 10 years ago

I have a shiny application that presents a user with a list of tables to view. The default table is displayed using renderDataTable(). Meanwhile, I present the column names and their definitions in a separate (updatable) table in the side bar. I am looking for a way to present additional descriptors (units, factor level definitions) when the user hovers/clicks elements in the sidebar table. Does shinyBS support a mechanism for this? I'm guessing popovers will not work, per the disclaimer: "currently cannot contain shiny inputs or outputs".

ebailey78 commented 10 years ago

There is something you could try, though some understanding of jQuery/CSS will help. shinyBS uses jQuery to select page elements based on their id. When shiny passes the id attribute to the output page, it prepends a "#" to indicate an id. There is nothing stopping you from expanding that id attribute to contain additional css selectors. for example, lets say your side table has an id of sideTable. If you wanted to add a tooltip to the first column header you could do something like this:

addTooltip(session, "sideTable th:nth-child(1)", "This is a tooltip")

The problem is the elements of the table aren't there when the page first loads so there isn't anything for the selector to select... As it stands now, you would need to write some sort of observer that fires after the table is rendered in order for jQuery to find the table cells.

I tested this on the Tables tab of bsDemo() by calling addTooltip() at the same time highlightCells() is called and it works, but it isn't exactly convenient.

Does this help?

bergsmat commented 10 years ago

That helps, thanks! It gives me a much better appreciation for the breadth of the problem. I plan to try your suggestion.