0
votes

How do I show Whitespace in a rendered DataTable on a Shiny App?

When running the App below - the user can double click to edit a cell and see the leading whitespace in the dataframe 'values'.

I dont know how to make the whitespace visible otherwise though!

library(shiny)
library(DT)
    ui = fluidPage(dataTableOutput("mytable"))
    server = function(input, output){
      values = data.frame(Demographics = c("Total", "Split_A", "Split_B", "Split_B1", "Split_B2"),check.names = F)

      output$mytable <- renderDT(
        values,
        selection = 'none',
        rownames = FALSE,
        escape   = FALSE,
        editable = T
      )
    }
  shinyApp(ui, server)
1
I think this is a feature because of html, probably would have to change the source code to get another resultBruno

1 Answers

0
votes

Kindly answered by nirgrahamuk on https://community.rstudio.com/

ui = fluidPage(
               tags$style("#mytable { white-space:pre; }"),
                dataTableOutput("mytable")
               )