I am attempting to display various R Shiny inputs within a Shiny DT without any unwanted line breaks. When I use the shinyInput function to concatenate text and HTML tags, both the text and inputs are displayed but line breaks occur before and after the input.
I suspect that the issue lies with the div tag causing this, however, adding the style="display:inline;" CSS code as suggested online does not resolve it; in fact, it disrupts the width definition.
Do you have any suggestions on how to keep the text before, the div, and the text after all within the same cell?
Below is some code provided for experimentation:
library(DT)
ui <- basicPage(
h2("The mtcars data"),
DT::dataTableOutput("mytable")
)
server <- function(input, output) {
shinyInput <- function(FUN, len, id, ...) {
inputs <- character(len)
for (i in seq_len(len)) {
inputs[i] <- as.character(FUN(paste0(id, i), ...))
}
inputs
}
mtcarsx <- data.frame(mtcars, newvar=
paste0(
"text before "
,shinyInput(checkboxInput,nrow(mtcars),"mychbx",label="",value=FALSE,width=NULL),
" text after"))
output$mytable = DT::renderDataTable({
DT::datatable(mtcarsx,
escape = FALSE,
selection = 'none',
rownames = FALSE,
extensions = 'RowGroup',
options = list(searching = FALSE,
ordering = FALSE,
rowGroup = list(dataSrc=c(1)),
columnDefs = list(list(visible=FALSE, targets=c(1)))
))
})
}
shinyApp(ui, server)