【问题标题】:Empty "row-fluid" div at top and bottom of dataTableOutputdataTableOutput 顶部和底部的空“行流体”div
【发布时间】:2014-09-08 04:12:49
【问题描述】:

我有一个使用 renderDataTable() 创建输出的闪亮示例。

我已删除所有可能的选项(分页、过滤、搜索等)。但是,我的表格输出的顶部和底部现在有一个空白行,以前是过滤和搜索的位置。

只有在删除了过滤和搜索选项后,如何才能从数据表包装器中删除这两个 div?

ui.R:

library(shiny)
shinyUI(pageWithSidebar(
  headerPanel("dataTable Example"),
  sidebarPanel(
    "This is a sidebar"
  ),
  mainPanel(
    p("Check out the gaps below."),
    wellPanel(
               dataTableOutput('example1')),
    p("No gaps here because of searching and paging."),
    wellPanel(
               dataTableOutput('example2')
        )
    )
  )
)

服务器.R:

library(shiny)
    shinyServer(function(input, output) {
      x<-c(1,2,3,4,5)
      y<-c('a','b','c','d','e')
      test<-data.frame(x,y)
      output$example1<-renderDataTable({test},options = list(iDisplayLength = 5,bSearchable = FALSE
                                                            ,bFilter=FALSE,bPaginate=FALSE,bAutoWidth=TRUE
                                                            ,bInfo=0,bSort=0))  
      output$example2<-renderDataTable({test})  
    })

【问题讨论】:

    标签: r datatables shiny


    【解决方案1】:

    您可以使用sDom 选项了解更多详情,请参阅http://legacy.datatables.net/usage/options#sDom

    library(shiny)
    runApp(list( ui =pageWithSidebar(
      headerPanel("dataTable Example"),
      sidebarPanel(
        "This is a sidebar"
      ),
      mainPanel(
        p("Check out the gaps below."),
        wellPanel(
          dataTableOutput('example1')),
        p("No gaps here because of searching and paging."),
        wellPanel(
          dataTableOutput('example2')
        )
      )
    )
    , server = function(input, output) {
      x<-c(1,2,3,4,5)
      y<-c('a','b','c','d','e')
      test<-data.frame(x,y)
      output$example1<-renderDataTable({test},options = list(iDisplayLength = 5,bSearchable = FALSE
                                                             ,bFilter=FALSE,bPaginate=FALSE,bAutoWidth=TRUE
                                                             ,bInfo=0,bSort=0
                                                             , "sDom" = "rt"
                                                             ))  
      output$example2<-renderDataTable({test})  
    }
    )
    )
    

    【讨论】:

      猜你喜欢
      • 2016-02-03
      • 2020-09-21
      • 1970-01-01
      • 1970-01-01
      • 2020-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多