空的“排液"dataTableOutput 顶部和底部的 div [英] Empty "row-fluid" div at top and bottom of dataTableOutput

查看:19
本文介绍了空的“排液"dataTableOutput 顶部和底部的 div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a shiny example using renderDataTable() to create an output.

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

I have removed all possible options (paging, filtering, searching, etc). However, there is now a blank row at the top and bottom of my table output, where the filtering and searching used to be.

如何才能从数据表包装器内部删除这两个 div,仅当我删除了过滤和搜索选项?

How can I remove these two divs from inside the datatable wrapper, only when I have removed the filtering and searching options?

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')
        )
    )
  )
)

server.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})  
    })

推荐答案

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

You can use the sDom option see http://legacy.datatables.net/usage/options#sDom for more details:

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})  
}
)
)

这篇关于空的“排液"dataTableOutput 顶部和底部的 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆