I am have an issue getting my datatable to render with formatStyle() in Shiny Server Pro using DT 0.1.
The datatable works great without the formatStyle(). I have verified that formatStyle() is working without error, however my table just does not render with formatStyle() in place. If I comment out formatStyle() everything works, just without colors.
Does formatStyle() not work with certain extensions/plug-ins? Code is below.
colors <- brewer.pal(12, "Set3") #setting color palette
pal <- colorRampPalette(colors) #function to create variable colors based on number of sources
finalDataset <- deidentified[,c("Source","Date","Feedback")]
brks <- unique(finalDataset$Source) #generating the unique values in Source
clrs <- pal(length(unique(finalDataset$Source))) #generating the proper number of colors based on the unique Source values
datatable(finalDataset, #create dataTable as subset of deidentified dataset with 3 columns
extensions = 'Scroller', #use the scroller extension for better table viewing
filter = 'bottom', #add filters at the bottom of the page
options = list(order = list(list(1, 'desc')), #order entries by newest to oldest date
language = list(search = 'Keyword Search:'), #change title of search bar to "Keyword Search"
searchDelay = 1000, #add delay to limit calls on large datasets
deferRender = TRUE, #increase performance by only rendering what is on screen
scrollY = 500, #the height of the scroll table enabled by the Scroller extension
scrollCollapse = TRUE, #allows the scroll window to shrink to dataset size if smaller than scrollY
columnDefs = list(list(width = '125px', targets = c(0))), #sets the width of the first column
autowidth = TRUE, #autowidth the other columns
searchHighlight=TRUE, #highlight the keywords in the searches. futher customization in css files
lengthMenu = c(5,25,100), #options of how many results are initially returned
pageLength = 25, #default length of the above options
server = TRUE #enable server side processing for better performance
), rownames = FALSE, selection="none") %>%
formatStyle('Source',target = 'row', color = styleEqual(c(brks),c(clrs))) #color the text of each row depending on their 'Source' value
Thanks,
Logan