R Shiny DataTable is transparent

I have created a shiny App with a data table. If i run the app everything is fine. But if i gave the app code to a friend and he runs the app the table doesn't have any background color and is transparent (see picture below). Does anybody have an idea why the table is is displayed incorrectly? Thanks.

output$mytable <- DT::renderDT(tabelle,rownames = FALSE,style="auto",filter="top",callback=JS('$('div.has-feedback input[type="search"]').attr( "placeholder", "Filter" )'), options = list(autoWidth = TRUE,scrollX = TRUE,language = list(sInfoThousands=".",zeroRecords="Keine Daten gefunden.",lengthMenu="Zeige MENU Einträge",search = "Suche",info = 'Insgesamt TOTAL Zeilen. Angezeigt werden START bis END Elemente.',sInfoFiltered ="(gefiltert von MAX Einträgen)",paginate =list('next'="vor", previous="zurück"))))

...
Wrong View:

I'm not sure why it is transparent, but you can try "forcing" the background and opacity by adding the line below. Adjust the color and opacity as needed.

DT::formatStyle(0:8, backgroundColor = 'white', opacity = 1)

Thanks for the answer but i get the following error:

Error in formatColumns(table, columns, tplStyle, valueColumns, match.arg(target), :
Invalid table argument; a table object created from datatable() was expected

The line needs to be added at the end of the creation of the datatable, like below. Does that work?

DT::datatable(tabelle,
             rownames = FALSE,
             style="auto",
             filter="top",
             callback=htmlwidgets::JS('$('div.has-feedback input[type="search"]').attr( "placeholder", "Filter" )'),
             options = list(autoWidth = TRUE,
                            scrollX = TRUE,
                            language = list(sInfoThousands=".",zeroRecords="Keine Daten gefunden.",
                                            lengthMenu="Zeige MENU Einträge",
                                            search = "Suche",
                                            info = 'Insgesamt TOTAL Zeilen. Angezeigt werden START bis END Elemente.',
                                            sInfoFiltered ="(gefiltert von MAX Einträgen)",
                                            paginate =list('next'="vor",
                                                           previous="zurück"))
                            )
             ) |>
  DT::formatStyle(0:8, backgroundColor = 'white', opacity = 1)

No unfortunately i get the error as written above. But i got also output$mytable <- DT::renderDT(tabelle... and not DT::datatable(tabelle,....

I changed it to this but still the same error:

output$mytable <- DT::renderDT(DT::datatable(tabelle,rownames = FALSE,style="auto",filter="top",callback=JS('$(\'div.has-feedback input[type="search"]\').attr( "placeholder", "Filter" )'),options = list(autoWidth = TRUE,scrollX = TRUE,language = list(sInfoThousands=".",zeroRecords="Keine Daten gefunden.",lengthMenu="Zeige _MENU_ Einträge",search = "Suche",info = 'Insgesamt _TOTAL_ Zeilen.  Angezeigt werden _START_ bis _END_ Elemente.',sInfoFiltered	="(gefiltert von _MAX_ Einträgen)",paginate =list('next'="vor", previous="zurück")))))%>%
  DT::formatStyle(0:8, backgroundColor = 'white', opacity = 1)

Error in formatColumns(table, columns, tplStyle, valueColumns, match.arg(target), :
Invalid table argument; a table object created from datatable() was expected

you haven't put it in the correct place yet.
if modifies the DT::datatable that gets passed into DT::renderDT,( whereas you have it modifying renderDT which will not work)

Thanks for the reply.
So where do i have to put the code:
DT::formatStyle(0:8, backgroundColor = 'white', opacity = 1)
?

probably this:

output$mytable <- DT::renderDT(
  DT::datatable(tabelle,
    rownames = FALSE,
    style = "auto",
    filter = "top",
    callback = JS('$(\'div.has-feedback input[type="search"]\').attr( "placeholder", "Filter" )'),
    options = list(
      autoWidth = TRUE,
      scrollX = TRUE,
      language = list(
        sInfoThousands = ".",
        zeroRecords = "Keine Daten gefunden.",
        lengthMenu = "Zeige _MENU_ Eintrage",
        search = "Suche",
        info = "Insgesamt _TOTAL_ Zeilen.  Angezeigt werden _START_ bis _END_ Elemente.",
        sInfoFiltered = "(gefiltert von _MAX_ Eintragen)",
        paginate = list("next" = "vor", previous = "zuruck")
      )
    )
  ) %>%
    DT::formatStyle(0:8, backgroundColor = "white", opacity = 1)
)

It worked. Thank you very much.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.