【问题标题】:renderDataTable in shiny is showing column search at bottom but I want it on top闪亮的 renderDataTable 在底部显示列搜索,但我希望它在顶部
【发布时间】:2022-01-04 23:12:04
【问题描述】:

我有以下代码用于闪亮的应用程序:

library(shiny)
library(tidyverse)
data_for_table <- read_csv("data/ForStatAnalysis.csv") %>% select(-ElectionYear ) %>% select(-State_abb) %>% rename('Total Migration'=totalMigration)


shinyServer(function(input, output) {

output$base_data <- renderDataTable(
  data_for_table,
  options=list(
    pageLength = 10, scrollX=TRUE 
    )
  )
     

)

})

这使用搜索列(我喜欢)呈现,但是,搜索列位于网格的底部,这很奇怪。 它看起来像这样: 我在https://datatables.net/reference/option/ 尝试了各种选项,但我似乎无法弄清楚哪个参数会使列搜索出现在网格的顶部。 有谁知道如何将这些列搜索器移到网格顶部?

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案1】:

    我需要添加 DT 库和 filter="top",如下所示。

    library(shiny)
    library(tidyverse)
    library(DT)
    data_for_table <- read_csv("data/ForStatAnalysis.csv") %>% select(-ElectionYear ) %>% select(-State_abb) %>% rename('Total Migration'=totalMigration)
    # Define server logic required to draw a histogram
    shinyServer(function(input, output) {
    
        output$base_data <- renderDataTable(
          data_for_table,filter="top",
          options=list(
            pageLength = 10, scrollX=TRUE,  options = list(
              columns = list(searchable = FALSE)
            )
          )
             
    
        )
    
    })
    

    【讨论】:

      猜你喜欢
      • 2014-05-02
      • 2022-08-17
      • 2010-09-26
      • 2021-02-24
      • 2013-07-12
      • 2012-09-25
      • 2017-05-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多