I am using R shiny to present data and want to move filter of datatable from bottom to top. I have already got answer from * suggests to change CSS. But I am not familiar with CSS, can anyone tell me how to modify CSS in renderDataTable
function? Thanks!
我正在使用R闪亮来表示数据,并希望将datatable的过滤器从底部移动到顶部。我已经得到了*关于改变CSS的建议的答案。但是我不熟悉CSS,有人能告诉我如何在renderDataTable函数中修改CSS吗?谢谢!
reference link: How to place DataTables column filter on top
参考链接:如何在顶部放置DataTables列过滤器
I tried the following, but doesn't work:
我试了一下,但没有用:
output$obs <- renderDataTable({data()},
options = list(aoColumnDefs = list(list(fnFilter$tfoot(display = "table-header-group"))))
)
1 个解决方案
#1
4
I'm not sure that's the best way to do it but you can "overwrite" the css of "tfoot" elements :
我不确定这是不是最好的方法,但是你可以“覆盖”tfoot元素的css:
Using for example this line in your Ui :
例如,在Ui中使用这一行:
tags$head(tags$style("tfoot {display: table-header-group;}"))
Though, it can be a problem if you have other tables with footer which you don't want at the top of the tables.
但是,如果您有其他带有页脚的表,而您不希望页脚位于表的顶部,则可能会出现问题。
#1
4
I'm not sure that's the best way to do it but you can "overwrite" the css of "tfoot" elements :
我不确定这是不是最好的方法,但是你可以“覆盖”tfoot元素的css:
Using for example this line in your Ui :
例如,在Ui中使用这一行:
tags$head(tags$style("tfoot {display: table-header-group;}"))
Though, it can be a problem if you have other tables with footer which you don't want at the top of the tables.
但是,如果您有其他带有页脚的表,而您不希望页脚位于表的顶部,则可能会出现问题。