add sliderinputs for all the rows in a table


instead of checkboxes i need sliderinputs.Is there a way to do it?

yes, the same approach that worked for checkboxes would work for sliderinputs.

no that didnt work for sliderinputs!!

well, what approach did you use ?

1 Like

checkbox<-rep(F,nrow(fd))
for checkboxes i used this

and what is F ?
if its making a checkbox, you should change it to make a slider inputs

F is usually a shortut for FALSE , so this line of code you shared, only makes FALSE, FALSE , FALSE ... etc vector for as many rows are in data.frame fd.
This code line on its own will not make a checkbox.

ok but is there any solution for sliders for all the rows?

Didn't we cover that in my first reply ?

no.thats not working!!

Are you starting from scratch with zero code ?
or do you have the start of anything relevant?
you hinted that you had code that at least made checkboxes...
You havent shared the relevant code.

library(shiny)
library(rhandsontable)
shinyUI(fluidPage(
rHandsontableOutput("tabled"),
)
)
library(shiny)
library(rhandsontable)
fd<-data.table(iris[1:5,])
fd$checkbox<-rep(F,nrow(fd))
print(fd)
shinyServer(function(input, output) {

output$tabled<-renderRHandsontable({rhandsontable(fd)})

})
with this i got checkboxes

On the one hand I want to offfer you an apology, I was perhaps too confident/flippant that it would be straightforward to get sliderInputs in a shiny DT context, as checkboxes. I think because sliderInputs are further away from base HTML , and involve javascript, the solutions for combining them in a shiny DT context, are convoluted, but possible. Here is a stackoverflow solution regarding it.
javascript - Shiny widgets in DT Table - Stack Overflow

However,
Your example code does not involve DT, (my wrong assumption) , you are using rhandsontable.
rhandsontable offers checkboxes produced in the way you show as anexample, as a feature.
If they don't offer a sliderInput feature, you may be out of luck, or at least may need to look elsewhere than rhandsontable, or make a feature request to rhandsontable !
rhandsontable (jrowen.github.io)

Good luck !

1 Like

Hi
I have a shiny app that dynamically generates sliders for numeric fields and select input for character fields with multiple selections. please watch my YouTube video.

There is a link to download R script. Hope it helps.

1 Like

thankyou @nirgrahamuk i think that would help

library(shiny)
library(DT)

ui <- fluidPage(
 
  fluidRow(
    
            sliderInput(inputId = "slider",
                                 label = "SLIDER",
                                 min = 0,
                                 max = 10,
                                 value = 5),
  ),
  
  fluidRow(DTOutput("table"))
)



js <- c(
  "function(settings){",
  "  $('[id^=Slider]').ionRangeSlider({",
  "    grid: true,",
  "    min: 0,",
  "    max: 200,",
  "    from: 5,",
 
  "  });",
  "}"
)

server <- function(input, output, session) {
  
  output$table <- renderDT({
    data <- data.frame(
      #ROW = 1:nrow(iris),
                       iris,
                       #SLIDER = '<input type="text" id="s" name="slider" value="" />',
                       SLIDER = sapply(1:nrow(iris), function(i) {
                         sprintf('<input type="text" id="Slider%d" name="slider" value="" />', i)
                       }),
                      
                       stringsAsFactors = FALSE)
    datatable(data = data,
              selection = "none",
              escape = FALSE,
              rownames = FALSE, 
              options = 
                list(
                  dom = 't',scrollX = TRUE,scrollY = TRUE,
                  initComplete = JS(js),
                  preDrawCallback = JS('function() { Shiny.unbindAll(this.api().table().node()); }'),
                  drawCallback = JS('function() { Shiny.bindAll(this.api().table().node()); } ')
                )
    )
    
  })
  
}

shinyApp(ui = ui, server = server)

is it possible to take the input of silders and do sum aggregation like average or sum?

refreshing the page makes the sliders disappear and also sliders are appearing only for first page