Reputation: 1
Is there a way to underline values in DT table . Example
library(shiny)
library(DT)
ui <- fluidPage(
dataTableOutput("iris")
)
server <- function(input, output, session) {
output$iris <- renderDataTable(datatable(head(iris)))
}
shinyApp(ui, server)
In the above application, is there a way to underline any values ? (example value (2,3) , meaning 2nd row and 3rd column value)
Upvotes: 0
Views: 168
Reputation: 84659
library(DT)
underlineCells <- function(rows, cols){
stopifnot(length(rows) == length(cols))
c(
"function(row, data, num, index){",
sprintf(" var rows = [%s];", paste0(rows-1, collapse = ",")),
sprintf(" var cols = [%s];", paste0(cols, collapse = ",")),
" for(var i = 0; i < rows.length; ++i){",
" if(index == rows[i]){",
" $('td:eq(' + cols[i] + ')', row)",
" .css({'text-decoration': 'underline'});",
" }",
" }",
"}"
)
}
datatable(iris,
options = list(
dom = "t",
rowCallback = JS(underlineCells(c(1,3), c(2,1)))
)
)
Upvotes: 1