rhandsontable
rhandsontable copied to clipboard
Search functionality for multiple rhandsontables in a shiny app
I have a shiny app with multiple tabs in which I am rendering rhandsontable and would like to provide a search capability. This is the module I have written for rendering such a table with search :
# Module for rendering rhandsontable with search
rtable_UI <- function(id) {
ns <- NS(id)
tagList(
textInput("searchField", "Search"),
rhandsontable::rHandsontableOutput(ns('table_output'))
)
}
rtableServer <- function(id, df) {
moduleServer(id, function(input, output, session) {
output$table_output <- rhandsontable::renderRHandsontable({
rhandsontable::rhandsontable(df, search = TRUE)
})
})
}
Note that searchField is not in its namespace. If I try ns("searchField" )
the search functionality does not work in my shiny app:
# Shiny App
ui <- navbarPage(
"example",
tabPanel(
'First Tab',
rtable_UI('table1')
),
tabPanel(
'Second Tab',
rtable_UI('table2')
)
)
server <- function(input, output, session){
rtableServer('table1', iris)
rtableServer('table2', mtcars)
}
shinyApp(ui, server)
The search functionality only works for the first tab and I think that’s because the ids of the search fields are the same. However changing the id also doesn’t seem to be an option. Is there some way of making the rhandsontable aware of the namespace?
Is this likely to be addressed?
Here's a temporary fix for now.