R Shiny:如何在DT :: renderDataTable中添加分页功能

3

我正在尝试在我的R Shiny应用程序中添加分页、搜索框和选择器,但现在它还不能正常工作(如您下面所见,我已经尝试了paging = TRUE和searching = 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"
                           ))

我已经添加了一个现有表格的截图和期望的表格。 感谢您的帮助![enter image description here]1

1个回答

6

您可以修改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')
  ))

enter image description here


为了增加页面长度,还需在字符串中添加l。希望这能帮到你!

谢谢,通过添加dom='Bftsp',现在功能已经出现了! - Remi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接