本文介绍了R Shiny:如何在DT :: renderDataTable中添加分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的R Shiny应用程序中添加分页,搜索框和选择器,但是暂时不起作用(我尝试在选项中看到分页= TRUE和search = TRUE,但可以看到,但是它没有工作)。您对我应该添加的内容有任何想法吗?

  output $ mytable1<-DT :: renderDataTable(
DT :: datatable(
{plots.dfs()[[1]]},
caption = htmltools :: tags $ caption(
style ='caption-side:bottom; text- align:center;',
'表2:',htmltools :: em('这是表的简单标题。')
),
扩展名='按钮',

选项=列表(
分页= TRUE,
搜索= TRUE,
fixedColumns = TRUE,
autoWidth = TRUE,
排序= TRUE ,
dom =' tB',
按钮= c('copy','csv','excel')
),

class = display
))

我添加了我现在拥有的表以及预期表的屏幕截图。
感谢您的帮助]






要添加页面长度,还请在字符串中添加 l 。希望这会有所帮助!


I am trying to add pagination, search box and selector in my R Shiny app, but it doesn't work for now (I tried paging = TRUE and searching = TRUE, in options as you can see bellow but it doesn't work). Do you have any idea of what I should add?

output$mytable1  <- DT::renderDataTable(
                            DT::datatable(
                                { plots.dfs()[[1]] },
                                caption = htmltools::tags$caption(
                                    style = 'caption-side: bottom; text-align: center;',
                                    'Table 2: ', htmltools::em('This is a simple caption for the table.')
                                ),
                                extensions = 'Buttons',

                                options = list(
                                    paging = TRUE,
                                    searching = TRUE,
                                    fixedColumns = TRUE,
                                    autoWidth = TRUE,
                                    ordering = TRUE,
                                    dom = 'tB',
                                    buttons = c('copy', 'csv', 'excel')
                                ),

                                class = "display"
                           ))

I have added a screenshot of table I have now, and the expected table.Thanks for your help]1

解决方案

You can modify the dom parameter, for example as follows:

DT::datatable(
  { mtcars },
  caption = htmltools::tags$caption(
    style = 'caption-side: bottom; text-align: center;',
    'Table 2: ', htmltools::em('This is a simple caption for the table.')
  ),
  extensions = 'Buttons',

  options = list(
    fixedColumns = TRUE,
    autoWidth = TRUE,
    ordering = TRUE,
    dom = 'Bftsp',
    buttons = c('copy', 'csv', 'excel')
  ))



To add page length, also add l to the string. Hope this helps!

这篇关于R Shiny:如何在DT :: renderDataTable中添加分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 02:57