简体   繁体   English

无法在Shiny中的DT :: renderdatatable中显示页码

[英]Unable to display page numbers in DT::renderdatatable in Shiny

I am trying to render a data table in Shiny but the output doesn'r display the page numbers. 我试图在Shiny中呈现数据表,但输出不显示页码。

I have tried changing the Paging, DOM options to various parameters but couldn't make it work 我已经尝试将Paging,DOM选项更改为各种参数但无法使其工作

DT::renderDataTable(expr = { 
    sales_data_filtered() %>%
        group_by(class) %>%
        summarise(sales = sum(sales))%>%
    mutate(sales = scales::dollar(sales)) 

}, options = list(scrollY = "250px",dom = 't',
    pageLength = 5) )

在此输入图像描述

Try to rewrite that a little bit. 尝试重写一点。

  1. Store the result in a seperate reactive expression: 将结果存储在单独的反应表达式中:
result <- sales_data_filtered() %>%
            group_by(class) %>%
            summarise(sales = sum(sales))%>%
            mutate(sales = scales::dollar(sales)) 

Why exactly do you use the dom = 't' option? 为什么要使用dom = 't'选项? It means, only the table will get rendered. 这意味着,只有表格才会被渲染。 If not needed, get rid of it. 如果不需要,摆脱它。

DT::renderDataTable(result(),
              options = list(
                  scrollY = "250px",
                  pageLength = 5,
                  lengthMenu = c(5, 10, 15, 20)
              ))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM