acircleda
acircleda

Reputation: 759

Place pagination at top of DT Datatable in R?

I'm working with a very long datatable and would like to place the pagination (1, 2, 3, ...15, next) at the top rather than the bottom of the table.

I know the DOM elements can be included/excluded as an option, but I don't see how to actually move them around.

How can a simple table like this move the pagination to the top?

library(DT)
datatable(iris)

Upvotes: 5

Views: 1925

Answers (2)

mrhellmann
mrhellmann

Reputation: 5529

The "dom" argument passed as a list in the options argument to datatable seems to arrange things.

datatable(head(iris, 30), options = list(dom = '<lfp<t>i>'))

enter image description here The t is for the table, p for pagination, between < and < at the top, between > and > at the bottom.

datatable(head(iris, 30))

enter image description here

Upvotes: 2

dww
dww

Reputation: 31452

You can use dom options. See https://datatables.net/reference/option/dom for details on the various options available. To place pagination at top use:

datatable(iris, options = list(dom = '<"top" p>'))

enter image description here

If you also need other elements such as information and search, add them in the same way, e.g.

datatable(iris, options = list(dom = '<"top" pif>'))

enter image description here

Upvotes: 6

Related Questions