Change mouse cursor to hand (pointer) in R Shiny

百般思念 提交于 2019-12-25 04:37:11

问题


How I can change the mouse over icon to pointer (hand) when user hover over data table cells.I am having 4 columns in a datatable and the 4th column row cells is diplaying tool tip on mouse over. I need to change the cursor icon to pointer when tool tip is displayed.I think this can be achieved through dt package options & JS but no success till now,Any Tips to achieve the same in R Shiny UI.


回答1:


Used CSS Script with rowCallback feature of DT Package to achieve this.Here is the code for iris datatable :

library(shiny)
library(DT)

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

output$irisTable <- DT::renderDataTable({
  DT::datatable(datasets::iris, 
                options = list(rowCallback = JS(
                  "function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {",
                  "var full_text = aData[1] + ','+ aData[2] + ',' + aData[3] + ','+ aData[4];",
                  "$('td:eq(5)', nRow).attr('title', full_text);", # Tool Tip
                  "$('td:eq(5)', nRow).css('cursor', 'pointer');", # Cursor icon changes to hand (pointer) on Hover
                  "}")
                )
  )

})
}
)


来源:https://stackoverflow.com/questions/40836947/change-mouse-cursor-to-hand-pointer-in-r-shiny

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!