0

I have a shiny app with list of wellPanels. They are used in jqui_sortable from shinyjqui. Panels are generated in server part (to uiOutput in ui). Order of panels can be changed by mouse and is written to file (by ids). Then I would like to open this file and change default order with loaded data.

Issue: I can't get out of rendered words "div" between panels (run code below).

Code was written with some lines from solution (thanks to @TimTeaFan):
Distorted spacing between div elements after sorting with jqui_sortable

library(shiny)
library(shinyjqui)

ui <- fluidPage(
  sidebarLayout(fluid = TRUE,
                sidebarPanel(helpText("HelpText")),
                mainPanel(
                  fluidRow(column(12,
                                  actionButton(inputId = "btn1",label = "Button1"),
                                  tags$style(HTML(".ui-sortable {
                                    width: 1200px !important;
                                    } ")),
                                  uiOutput('multiobject'),
                                  actionButton(inputId = "btn2",label = "Button2")
                  )) 
                )       
  )
)
server <- function(input, output, session) {
  sortableorderednameList<-reactiveVal(
    c("A","B","C")
  )
  wpFunc <- function(v,name,helptext){
    return(tags$div(wellPanel(id=paste0(v,"P"),
                              div(style="display: inline-block;  width: 10px;",
                                  checkboxInput(paste0(v,"Chk"), label = NULL, value = TRUE)),
                              div(style="display: inline-block;  width: 150px;",
                                  textInput(paste0(v,"TI"), label = NULL, value = name)),
                              div(style="display: inline-block;",helpText(helptext)), 
                              style = "padding: 1px;")))
  }
  observe({
    if(is.null(input$sortablecollistJQ_order$id)) {return()}
    mylist <- input$sortablecollistJQ_order$id
    mylist <- unlist(lapply(mylist, function(v) substr(v,1,nchar(v)-1)))
    print(mylist)
    print(" ")
    isolate(sortableorderednameList(mylist))
  })
  output$multiobject <- renderUI({
    uiList <- list()
    for (v in sortableorderednameList()) {
      switch(v,
             "A" = {uiList <- append(uiList,wpFunc(v,"A","There is A"))},
             "B" = {uiList <- append(uiList,wpFunc(v,"B","There is B"))},
             "C" = {uiList <- append(uiList,wpFunc(v,"C","There is C"))}
      )
    }
    jqui_sortable(div(id = 'sortablecollistJQ',uiList))
  })
}

shinyApp(ui, server)
Big Z
  • 65
  • 7

1 Answers1

0

I have got an answer after experiments. If somebody is interested.

 for (i in 1:length(uiList)) {
    uiList[i] <- uiList[i]$children
  }

It changes structure of list, put it before jqui_sortable call.

Big Z
  • 65
  • 7