I am trying to use a callback in my shiny dashboard to collapse the rows in a datatable. I found that the callback works if I use shinydashboard but not when I semantic.dashboard library.
library(stringr)
library(glue)
library(insight)
library(devtools)
library(shiny)
library(shinysky)
library(DT)
library(tidyverse)
library(shiny.semantic)
library(shinydashboard)
library(semantic.dashboard)
# , color = 'red', inverted = TRUE, show_menu_button = FALSE
ui <- dashboardPage(dashboardHeader(title = 'hello'),
dashboardSidebar(
sidebarMenu(menuItem(tabname = "View", text = 'View'))),
dashboardBody(tabName = "wishlist",
fluidRow(column(width = 10,
box(
dataTableOutput("my_tableee"),
width = 8, title = 'Wislist',
color ='yellow', collapsible = FALSE))))
)
server <- function(input, output, session) {
output$my_tableee <- DT::renderDataTable({
datatable(
mtcars,
extensions = 'RowGroup',
options = list(rowGroup = list(dataSrc = c(2,11)),
pageLength = 20),
callback = JS(
"table.on('click', 'tr.dtrg-group', function (level) {",
" var rowsCollapse = $(this).nextUntil('.dtrg-group');",
" $(rowsCollapse).toggleClass('hidden');",
"});",
"table.one('init', () =>
$('#my_tableee .dtrg-group').trigger('click'))"
),
selection = 'single'
)
})
}
# Run the application
shinyApp(ui = ui, server = server)
For the above code the callback works if I start a R session with shinydashboard
. But I restart a R session with the semantic.dashboard
library