When a DT datatable initilaly renders in a shiny app it appears to grow from the top and push all other elements down the page. Is there a way to render the datatable more smoothly so that other elements are not pushed out of the way like this?
You can see in the example code the h1 renders first at the top of the screen and is then pushed down when the datatable renders. I have tried creating a div with minimum height for the table but it didn't work.
library(shiny)
library(DT)
ui <- fluidPage(
DT::dataTableOutput('table'),
h1('placeholder text'))
server <- function(input, output, session) {
my_data <-
data.frame(
a = rnorm(5000),
b = rnorm(5000),
c = rnorm(5000),
d = rnorm(5000)
)
output$table <- DT::renderDataTable({
datatable(my_data, options = list(pageLength = 25))
})
}
shinyApp(ui, server)
There is some nice functionality in the DT package to reload data smoothly when the data changes after the initial render (using replaceData()). However, I cannot seem to render the data smoothly initially.