4

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)

2 Answers 2

4

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

1
  • For pagination both at top and bottom: datatable(iris, options = list(dom = '<"top"lpf<"clear">>rt<"bottom"ip<"clear">>' )) Sep 1, 2021 at 11:26
0

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

2
  • this seems only incrementally different to my earlier answer
    – dww
    Jan 11, 2020 at 4:10
  • You must've posted while I was looking for the answer. Looks like we got to the same place, but you beat me by a few minutes, and with better formatting.
    – mrhellmann
    Jan 11, 2020 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.