Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/432.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在更改输入后保留滚动位置_Javascript_R_Shiny_Shinyjs_Shinywidgets - Fatal编程技术网

Javascript 如何在更改输入后保留滚动位置

Javascript 如何在更改输入后保留滚动位置,javascript,r,shiny,shinyjs,shinywidgets,Javascript,R,Shiny,Shinyjs,Shinywidgets,在Shinny中,我使用一个带有大量项目的水平按钮输入。如果单击其中一个项目,按钮标签的颜色将更改。这实际上很好用 但是,如果我单击最后一项中的一项以便向右滚动,滚动位置将重置 因此,每次单击后,如果我想继续下一项,我必须再次向右移动 是否有一种解决方案,可以在每次单击后保留滚动位置 代码如下: library(shiny) library(shinyWidgets) ui <- fluidPage(uiOutput("selItem")) server <- function(

在Shinny中,我使用一个带有大量项目的水平按钮输入。如果单击其中一个项目,按钮标签的颜色将更改。这实际上很好用

但是,如果我单击最后一项中的一项以便向右滚动,滚动位置将重置

因此,每次单击后,如果我想继续下一项,我必须再次向右移动

是否有一种解决方案,可以在每次单击后保留滚动位置

代码如下:

library(shiny)
library(shinyWidgets)

ui <- fluidPage(uiOutput("selItem"))

server <- function(input, output, session)
{
  global <- reactiveValues(itemNames=NULL, itemValues=NULL)

  observe(
  {
    options <- c("word01", "word02", "word03", "word04", "word05", "word06", "word07", "word08", "word09", "word10", "word11", "word12", "word13", "word14", "word15", "word16", "word17", "word18", "word19", "word20", "word21", "word22", "word23", "word24", "word25", "word26", "word27", "word28", "word29", "word30", "word31", "word32", "word33", "word34", "word35", "word36","word37", "word38", "word38", "word39", "word40", "word41", "word42", "word43", "word44", "word45", "word46", "word47")

    global$itemNames  = options
    global$itemValues = options
  })

  output$selItem <- renderUI(
  {
    fluidRow(
      style = "overflow-x: scroll;",
      radioGroupButtons(inputId = "replyItem", label = NULL, choiceNames = global$itemNames, choiceValues = global$itemValues, selected = character(0), individual = TRUE, width = "10000px")
    )
  })

  observeEvent(input$replyItem,
  {
    index <- which(global$itemValues==input$replyItem)
    global$itemNames[index] <- HTML(paste0("<span style='color: #0000ff'>", global$itemValues[index], "</span>"))
  })
}

shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(shinyWidgets)

ui尽管对于datatable,请查看这是否提供了任何线索,使fluidRow呈现反应性是问题所在。将fluidRow和style放入静态UI,只渲染单选组按钮。当然。否则,如果必须由服务器呈现fluidRow,则可能有一种方法来隔离()
fluidRow。使用
DT
datatable时,我会遇到类似的问题,