Skip to content

dq_render_handsontable not working when put in module #23

@FrankSchiro

Description

@FrankSchiro

I'm having trouble getting a shiny module to display the dqshiny handsontable. I think it is a namespace issue, but really, I have no idea. The table data does not display in the module example below. I also include an example of the code working when not using modules.

Nonworking code example using module:

library(shiny)
library(rhandsontable)
library(dqshiny)

# module UI ->
myModuleUI <- function(id) {
  ns <- NS(id)
  tagList(
    fluidRow(
        dq_handsontable_output(ns("dataTable"))
    )
  )
}
# module server ->
myModule <- function(input, output, session, df) {
    dq_render_handsontable("dataTable", df)
}
# Use the module in an application
ui <- fluidPage(
  myModuleUI("myModule1")
)
server <- function(input, output, session) {
    df = data.frame(
        company = c('a', 'b', 'c', 'd'),
        bond = c(0.2, 1, 0.3, 0),
        equity = c(0.7, 0, 0.5, 1),
        cash = c(0.1, 0, 0.2, 0),
        stringsAsFactors = FALSE
    )
  callModule(myModule, "myModule1",  df = df)
}
shinyApp(ui, server)

The code below works without using modules:

shinyApp(
  ui = fluidPage(
    dq_handsontable_output("dataTable")
  ),
  server = function(input, output, session) {
    df = data.frame(
        company = c('a', 'b', 'c', 'd'),
        bond = c(0.2, 1, 0.3, 0),
        equity = c(0.7, 0, 0.5, 1),
        cash = c(0.1, 0, 0.2, 0),
        stringsAsFactors = FALSE
    )
    dq_render_handsontable("dataTable", df)
  }
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions