R Shiny,从DataTables中删除列内过滤器

时间:2022-06-28 14:27:42

[also posted in Shiny Google Group]

[也发布在Shiny Google Group]

I am encountering some (I believe) unexpected behavior when I attempt to display a dataTable. When I display the table, my goal is to remove the majority of the sort/pagination/filter/processing options. So far setting bSort=0, bProcessing=0, bPaginate=0, bInfo=0 appears to produce desired results. However when I set bFilter=0, only the "global" filter box in the upper right had corner is removed; the within-column filter boxes remain (I expected bFilter=0 to remove all filter boxes).

当我尝试显示dataTable时,我遇到了一些(我相信)意外行为。当我显示表格时,我的目标是删除大多数排序/分页/过滤/处理选项。到目前为止,设置bSort = 0,bProcessing = 0,bPaginate = 0,bInfo = 0似乎产生了期望的结果。但是当我设置bFilter = 0时,只有右上角的“全局”滤镜盒被移除;列内过滤器框保留(我希望bFilter = 0以删除所有过滤器框)。

Can anyone help with code to remove the within-column filter boxes (please and thank-you). [Also, I am aware of the column-specific format options, but have so-far been unable to implement them successfully to eliminate the within-column formats]. I have included minimal code below to reproduce the problem:

任何人都可以帮助代码删除列内过滤器框(请和谢谢你)。 [另外,我知道特定于列的格式选项,但到目前为止还无法成功实现它们以消除列内格式]。我在下面包含了最少的代码来重现问题:

shinyUI(pageWithSidebar(

  #my code has a header panel;
  headerPanel("Table Example"),

  #my code has a sidebar panel;
  sidebarPanel(helpText("Stuff Here")),

  #table is displayed in the main panel;
  mainPanel(dataTableOutput("myTable"))
))


shinyServer(function(input, output) {

  #example dataTable that produces undesired result;
  output$myTable <- renderDataTable({
    as.data.frame(matrix(sample(1:10,100,replace=TRUE),nrow=20,ncol=10))
  }, options = list(bFilter=0, bSort=0, bProcessing=0, bPaginate=0, bInfo=0))

})

[Behavior appears both running from server and locally. Shiny 0.7.0.99. Using Google Chrome]

[行为显示从服务器和本地运行。闪亮0.7.0.99。使用谷歌浏览器]

Thanks-in-advance!

1 个解决方案

#1


7  

The solution was to simply edit the css associated with the myTable output object:

解决方案是简单地编辑与myTable输出对象关联的css:

I.e. change:

mainPanel(dataTableOutput("myTable"))

to

mainPanel(
  dataTableOutput("myTable"),
  tags$style(type="text/css", '#myTable tfoot {display:none;}')
) 

#1


7  

The solution was to simply edit the css associated with the myTable output object:

解决方案是简单地编辑与myTable输出对象关联的css:

I.e. change:

mainPanel(dataTableOutput("myTable"))

to

mainPanel(
  dataTableOutput("myTable"),
  tags$style(type="text/css", '#myTable tfoot {display:none;}')
)