Dear community,
I'm having the following problem after the latest R-update.
I operate a Shiny App producing a styled talbe as its main output, by using the "DT" package.
I want the first columns of my table to be fixed (freezed), and I am using the "FixedColumns" extension in DT to accomplish this.
Also, I want empty rows in my table to be colored, to mark separations between output blocks.
I accomplished this by targeting empty cells in a column that mantains its basic fromat throughout the table, and then extending the command to the whole respective row.
This is possible by using the "formatStyle()" option.
All this worked perfectly fine until I updated to the newest R-version a few days ago.
Now I am not able to make both features work simultaneously again... either I can freeze the columns, but without the empty row coloring, or I can mantain the coloring by renouncing to freeze columns.
Here is a simplified version of my code with an exemplary table taken from the "iris" data
(I added an empty row in the middle of the table , and I fixed the 3 first columns)
##############################################################################
library(shiny)
library(shinydashboard)
library(DT)
ui <- dashboardPage( dashboardHeader(), dashboardSidebar(), dashboardBody ( DTOutput( outputId = "Results_Table")))
server <- function(input, output ) {
dt <- rbind(iris[1:3,], rep(NA, ncol(iris)), iris[4:6,])
dt1 <- cbind(dt, dt, dt)
output$Results_Table <- renderDT (datatable( dt1,rownames= F, class = "compact",
extensions = c("FixedColumns"),
options = list(scrollX = TRUE, pageLength = 100, scrollY = "450px", fixedColumns = list(leftColumns = 3)) )
%>% formatStyle(
columns = 3,
target = 'row',
backgroundColor = styleEqual(NA, "lightsteelblue")
))}
shinyApp(ui = ui, server = server)
##########################################################################################
If you remove the following line of code within formatStyle():
target = 'row',
you will see that the coloring still works on a single row/column basis.
However when trying to extend the coloring to the whole row by using the option "target = 'row'",
it does not work anymore when combined with the option to freeze columns.
Many thanks in advance for any kind of help!
Kind regards
Flavio