首页 > 解决方案 > 如何根据用户在RShiny中的选择对齐数据表

问题描述

我目前正在开发一个闪亮的应用程序,但我遇到了数据表动态对齐的问题。使用的代码是

用户界面

shinyUI(fluidPage(
  dashboardPage(
  dashboardBody(
      tabItems(
        tabItem(tabName = "view_id",
                sidebarLayout(
                  sidebarPanel(width = 2, checkboxGroupInput("sidebar", "People Viewer",
                                                  sidebar_content)

                  ),
                  mainPanel(width=10,style ="background-color:RGB(255,255,255); border-color:RGB(255,255,255);align:left;",
                            wellPanel(DTOutput("tab") )
                  )
                )

        )

      )

    )))

服务器.R

shinyServer(function(input, output) {

 output$tab <- {

    renderDT(datatable(pep_view[ ,input$sidebar, drop = FALSE  ], filter = 'top', extensions = 'FixedColumns',
                       options = list(scrollX = TRUE,scrollY = "400px" ,fixedColumns = TRUE, pageLength = 10, autoWidth = TRUE
                       ), class = 'cell-border stripe')

    )
  }
})

得到的输出是 在此处输入图像描述

任何人都可以解决这个问题吗?提前致谢!!

标签: rshinyshinydashboard

解决方案


推荐阅读