【问题标题】:R Shiny: How to add pagination in DT::renderDataTableR Shiny:如何在 DT::renderDataTable 中添加分页
【发布时间】:2018-10-07 03:54:43
【问题描述】:

我正在尝试在我的 R Shiny 应用程序中添加分页、搜索框和选择器,但它现在不起作用(我尝试了分页 = TRUE 和搜索 = TRUE,在选项中,您可以在下面看到,但它没有不工作)。你知道我应该添加什么吗?

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

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

【问题讨论】:

    标签: r shiny dt


    【解决方案1】:

    您可以修改dom参数,例如如下:

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


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

    【讨论】:

    • 感谢,通过添加 dom='Bftsp',功能现在出现了!
    猜你喜欢
    • 2015-09-13
    • 2015-10-07
    • 2020-05-02
    • 2016-10-18
    • 1970-01-01
    • 2018-10-06
    • 2018-10-08
    • 2018-08-07
    • 1970-01-01
    相关资源
    最近更新 更多