I currently have an app in R shiny using fluidPage. Within this app i have an interactive data table from which I select rows which brings up a modal window. See sample code below.
# Load packages
library(tidyverse)
library(readxl)
library("openxlsx")
library(segmented)
library(grid)
library(gridExtra)
library(shiny)
library(shinyWidgets)
library(shinydashboard)
library(DT)
library(dplyr)
library(shinyBS)
library(shinythemes)
data_table <- data.frame(c(1))
names(data_table)[1] <- "a"
data_table$b <- 2
data_table$c <- 3
ui <- fluidPage(theme = shinytheme("lumen"),
mainPanel(
tabsetPanel(
tabPanel("Dashboard",
fluidRow(
box(DTOutput("data_table"), title = "Selectable Data Table", width = 12)
),
tags$head(tags$style(HTML('
.modal-lg {
width: 99%;
}
')))
)
)
)
)
server <- function(input, output, session) {
#DASHBOARD
output$data_table <- DT::renderDataTable({
DT::datatable(data_table, selection = 'single', escape = FALSE)
})
table_select <- reactive({
input$data_table_rows_selected
})
observeEvent(table_select(),{
showModal(modalDialog(
title = "I wish this window had a layout similar to fliudPage",
size = "l",
easyClose = TRUE,
)
)
})
}
shinyApp(ui = ui, server = server)
However, in this modal window, I am not able to have the fluidPage layout i.e. row width of 12, setting fluidRows etc. I would like to have greater control of the layout of this modal window - preferably the same layout controls as a fluidPage.
the only thing I have been able to do is to create a larger modal window than what is normally presented using the following code:
tags$head(tags$style(HTML('
.modal-lg {
width: 99%;
}
')))
The way I see it I have two options:
Option 1 - Find a way to have the observeEvent open a new fluidPage instead of a modal window? or
Option 2 - change the modal window layout somehow...
any help would be greatly appreciated!
Cheers,
-Alex