I have a data table with a lot of text in some rows.
What I would like to do is to limit the default display of text in the row to 4 lines and then when the row is clicked to either expand it, or only display that specific row.
library(shiny)
library(DT)
data <- data.frame(
question = c("question1", "question2", "guestion3", paste0("A ", paste0(rep("very", 1000), collapse = " "), "long question"), "..."),
answer = c("answer1", "answer2", paste0("A ", paste0(rep("very", 1000), collapse = " "), "long answer"),
paste0("Another ", paste0(rep("very", 200), collapse = " "), "long answer"), "...")
)
ui <- fluidPage(
DT::dataTableOutput(('DTOut'))
)
server <- function(input, output) {
output$DTOut <- DT::renderDataTable({
data
})
}
shinyApp(ui = ui, server = server)
I was trying to play with max-height and toggle, however wasn't very successful there.