0

Can we add a small icon next to values in DT table. Example

if (interactive()) {
  library(shiny)
  library(shinyWidgets)
  library(DT)
  
  ui <- fluidPage(
    tags$h3("Material switch examples"),
    
    fluidRow(column(width = 12),
             fluidRow(box(width = 4, dateInput("date","Date", value = Sys.time(), min = Sys.time(), max = Sys.time()-30)),
                      box(width = 7, selectInput("df","DF",choices = unique(iris$Species)),offset = 0),
                      box(width = 2, actionButton("ab","Action")))),
    dataTableOutput("df")
  )
  server <- function(input, output) {
    
    output$df <- DT::renderDataTable({
      datatable(head(iris),caption = "Iris",options = list(dom = 'ft'))
    })
    
  }
  shinyApp(ui, server)
}

IN the above DT table, can we add upward arrow next to Setosa . (It should be clickable)

Expect Output

enter image description here

Vinod P
  • 89
  • 6

1 Answers1

0

You could use icon to display an up arrow.


  library(shiny)
  library(shinyWidgets)
  library(DT)
  library(dplyr)
  
  ui <- fluidPage(
    tags$h3("Material switch examples"),
    
   
    dataTableOutput("df")
  )

    server <- function(input, output) {
    
      
    data <- head(iris) %>% mutate(Species = paste(Species,as.character(icon("arrow-up", lib = "glyphicon")))) 
    output$df <- DT::renderDataTable({
      datatable(data,caption = "Iris",options = list(dom = 'ft'),escape=FALSE, selection = list(mode = 'single',target = 'cell'))
    })
    

  }
  shinyApp(ui, server)

enter image description here

Waldi
  • 39,242
  • 6
  • 30
  • 78
  • FIrst of all thanks for the efforts. Actually, you have put as separate column. But I am trying to put just next to "Setosa" (refer in Question) and not as a separate column :) Did I confuse you? – Vinod P Sep 23 '20 at 18:22
  • No problem to put the arrow next to setosa, see my edit. – Waldi Sep 23 '20 at 18:41
  • Still the same only :) – Vinod P Sep 23 '20 at 18:43
  • Great. Thanks. But for you reference, I tried in another way. Sorry I thought might have other solution but its same. https://stackoverflow.com/questions/63958260/issue-in-action-button/63962226#63962226 i am trying to solve this as well. It very difficult I am trying a lot. If you have time please see this :) Anyways really appreciate ur time dude :) – Vinod P Sep 23 '20 at 18:47
  • @Vinod, I won't have time to look further. Hopefully you'll find a solution that fullfils your needs! – Waldi Sep 23 '20 at 19:04
  • Thanks that’s fine – Vinod P Sep 23 '20 at 19:04