Skip to content

smContextMenu works for plots but not on datatable #1

@JillShellum

Description

@JillShellum

Below is a code that activates user defined menu option during right click on any specific object. In this example plot.

library(shiny)
library(shinyBS)
library(shinyMenus)

app <- shinyApp(
  ui = 
    fluidPage(
      smNavBar("testMenu", "shinyMB", full.width = TRUE, fixed = FALSE, 
               textInput("n", "Sample Size", value = 1000)
      ),

      plotOutput("testPlot"),

      smContextMenu("context1","testPlot",
                    smAction("action1", "Normal"),
                    smAction("action2", "Lognormal"),
                    smAction("action3", "Uniform")
      )
    ),
  server = 
    function(input, output, session) {
      output$testPlot <- renderPlot({
        plot(rnorm(input$n))
      })
    })

runApp(app)

If I try to trigger the same functionality on a datatable it does not work.

library(shiny)
library(shinyBS)
library(shinyMenus)

app <- shinyApp(
  ui = basicPage(
    h2('The mtcars data'),

    dataTableOutput('mytable'),

      smContextMenu("context1","mytable",

                    smAction("action1", "Cat"),
                    smAction("action2", "Dog"),
                    smAction("action3", "Exotic Bird")
      )
    ),
  server = 
    function(input, output, session) {
      output$mytable <- renderDataTable({
        mtcars
      })
    })

runApp(app)

Not sure what I am missing, any help is much appriciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions