Reputation: 111
I have searched and seen a few examples but cannot get it to work on my own (more experience needed) so some help would be amazing - I am using R shiny App and rendering a table
Example:
A B C D
a1 1 2 3
a2 4 5 6
a3 7 8 9
currently my data table loads a default of 10 rows - how may i set the option for 25 rows by default.
output$mytable <- DT::renderDataTable({ Forecast %>% filter(grepl(toupper(input$id_select),Name)) %>% arrange(Name, Title) })
Upvotes: 1
Views: 939
Reputation: 21425
You can use formatStyle
to change the color of the rows, here's an example:
library(shiny)
library(DT)
set.seed(100)
data <- data.frame(A=sample(c('a1','a2','a3'),10,replace=T),
B=1:10,
C=11:20,
D=21:30)
shinyApp(
ui = fluidPage(DT::dataTableOutput('tbl')),
server = function(input, output) {
output$tbl = DT::renderDataTable(
datatable(data, options = list(pageLength = 25)) %>%
formatStyle('A',target="row",backgroundColor = styleEqual(c('a1','a2','a3'),c("purple","purple","blue")))
)
}
)
There are a lot of examples for styling here
Upvotes: 1