In DT table/datatable in R shiny. When there is no data available. There is sentences telling "No data available". Wanted to check if we can move this sentence towards left. Currently it is displayed in the center
can anyone please help?
Below is the part from Rshiny
output$table <- DT::renderDT({
datatable(data2(......))
})
You have to change the td.dataTables_empty
CSS.
Outside Shiny, you can do:
library(DT)
dat <- data.frame(X = numeric(0), Y = numeric(0))
callback <- '$("td.dataTables_empty").css("text-align", "left");'
datatable(dat, callback = JS(callback))
This also works inside Shiny (declare callback
where you want, eg at the beginning of the app). But inside Shiny you can also change the CSS like this:
library(shiny)
library(DT)
dat <- data.frame(X = numeric(0), Y = numeric(0))
css <- "td.dataTables_empty {text-align: left !important;}"
ui <- fluidPage(
tags$head(tags$style(HTML(css))),
DTOutput("dtable")
)
server <- function(input, output, session){
output[["dtable"]] <- renderDT({
datatable(dat)
})
}
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.