简体   繁体   English

使用datatable()显示数据的最后一页

[英]Displaying last page of data with datatable()

In the DT library datatable() will draw the first page (default max of 10 rows) of a table DT库中, datatable()将绘制表的第一页(默认最多10行)

library(DT)
datatable(iris)

I have checked the documentation but could not find a suitable example for displaying a specific page (for example, the last page) in a table. 我已经检查了文档,但是找不到合适的示例来在表格中显示特定页面(例如,最后一页)。 I suppose this must be written with a Javascript callback. 我想这必须用Javascript回调编写。

callback the body of a JavaScript callback function with the argument table to be applied to the DataTables instance (ie table) 使用要应用于DataTables实例(即表)的参数表来回调JavaScript回调函数的主体

This callback, for example, will draw the second page in the table: 例如,此回调将在表中绘制第二页:

  datatable(head(iris, 30), callback = JS('table.page("next").draw(false);'))

How would one draw the last page, or a different, x th page? 一个人将如何绘制最后一页或另一张第x页?

table.fnPageChange( 'last' );

应该将您带到此处所述的最后一页

table.page("last") seems to work: table.page("last")似乎可以工作:

datatable(head(iris, 30), rownames=F,
          callback = JS('table.page("last").draw(false);'))

在此处输入图片说明

The relevant API reference is here: https://datatables.net/reference/api/page() 相关的API参考位于此处: https : //datatables.net/reference/api/page()

I included the rownames = F option since that was an issue with the other answer, but it's not required 我包括了rownames = F选项,因为这是另一个答案的问题,但这不是必需的

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

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