I am trying to make a Shiny app using golem, but I am very new to this. This time I just want to make a small table with checkboxes and a scroll bar, but I am not succeeding...
This is the only thing I manage to make work so far (but even the scrollbar does not seem to show):
mod_saving_side_ui <- function(id){
ns <- NS(id)
tagList(
shinyjs::useShinyjs(),
shinyalert::useShinyalert(),
fluidRow(
DT::DTOutput(ns("my_marker_table"), width = "75%")
)
)
}
mod_saving_side_server <- function(id, r){
moduleServer( id, function(input, output, session){
ns <- session$ns
output$my_marker_table <- DT::renderDT({
marker_df <- data.frame(marker=LETTERS, positive="", negative="")
marker_df$positive[1] <- "y"
marker_df$negative[2:4] <- "y"
marker_matrix <- as.matrix(marker_df)
DT::datatable(marker_matrix, options = list(scrollY = TRUE, sDom = '<"top">rt<"bottom">ip'), rownames = FALSE)
})
})
}
It produces this:
However I would like to accomplish 3 things:
Previous
1
2
3
Next
buttonspositive
and negative
columns have a checkbox per rowpositive
checkbox preselected for the first row A
, and the negative
checkbox preselected for the 2:4 rows B
, C
, D
How to make checkboxGroupInput
work in here and the scrollbar to show? Thanks!
Here's a partial answer, only focused on point 1. I think you should split this post into several ones, it's a bit discouraging when we see a list of things to do instead of a single question.
Also, your example is not reproducible (we can't just copy-paste your code to make the app), so I made a basic app instead.
Basically, I remove the "1", "2", "3", etc. buttons at the bottom of the datatable()
with the argument pageLength
. Only doing this produces a very long table, so I use CSS to specify its height (here I put 15em
but it's your choice) and to make it scrollable.
library(shiny)
library(DT)
ui <- fluidPage(
tags$head(
tags$style(
HTML(
"#test {
height: 15em !important;
overflow-y: scroll
}"
)
)
),
DTOutput("test")
)
server <- function(input, output, session) {
output$test <- renderDT({
datatable(iris, options = list(
pageLength = nrow(iris)
))
})
}
shinyApp(ui, server)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.