DT formatStyle() Not Rendering in Shiny Server Pro

800 views
Skip to first unread message

Logan Meltabarger

unread,
Oct 6, 2015, 1:16:08 PM10/6/15
to Shiny - Web Framework for R
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 

Yihui Xie

unread,
Oct 6, 2015, 2:25:04 PM10/6/15
to Logan Meltabarger, Shiny - Web Framework for R
Do you see any error messages in the JavaScript console of your web
browser? I don't quite remember if formatStyle(target = "row") is a
feature of the current development version
(https://github.com/rstudio/DT) or the CRAN version (0.1) of DT. Can
you also try the former?

Regards,
Yihui

Logan Meltabarger

unread,
Oct 6, 2015, 2:35:40 PM10/6/15
to Shiny - Web Framework for R, lrmelt...@gmail.com

I have tried it also without target="row" to no avail.

I am firewalled off from using devtools with github...how can I download the development version locally to install from source?

Here is the JS error: "SyntaxError: unterminated string literal htmlwidgets.js:2:143"

Thanks,
Logan

Yihui Xie

unread,
Oct 6, 2015, 3:16:10 PM10/6/15
to Logan Meltabarger, Shiny - Web Framework for R
Yes, you can install from the repo below if you cannot install from Github:

install.packages(
"DT",
type = "source",
repos = c("http://yihui.name/xran", "http://cran.rstudio.com")
)

But it seems the development version would not solve the problem,
since there is a syntactical JS error. I will need a minimal
reproducible example if the devel version does not work, either.

Regards,
Yihui


On Tue, Oct 6, 2015 at 1:35 PM, Logan Meltabarger
> --
> You received this message because you are subscribed to the Google Groups
> "Shiny - Web Framework for R" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to shiny-discus...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/shiny-discuss/28ac4427-4f22-47d2-b746-ce926b06f3d4%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Logan Meltabarger

unread,
Oct 6, 2015, 8:53:58 PM10/6/15
to Shiny - Web Framework for R, lrmelt...@gmail.com
I figured it out...the data had an unescaped '\n' built in so I need to change the data structure.

That fixed the rendering issue...now I am still interested in getting the dev version installed. I am behind firewalls, so I cannot use install calls that reference repos.

I did download the tar.gz from http://yihui.name/xran/ but it failed with a "non-zero exit status" then I tried to unpack the tar.gz to install from dir and it gave me this "tar: This does not look like a tar archive".

Any other method for someone behind firewalls?

But my error has been resolved.

Thanks,
Logan


Yihui Xie

unread,
Oct 6, 2015, 9:14:27 PM10/6/15
to Logan Meltabarger, Shiny - Web Framework for R
After you download DT_*.tar.gz, you can install it via

R CMD INSTALL DT_*.tar.gz

in the terminal. You should not and do not need to unpack it.

Regards,
Yihui
Reply all
Reply to author
Forward
0 new messages