Thank you. There is another way if you want to add buttons.
output$ex2 <- DT::renderDataTable(
DT::datatable(
iris,
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
lengthMenu = list(c(5, 15, -1), c('5', '15', 'All')),
pageLength = 15,
buttons = list(
list(
extend = "collection",
text = 'Show All',
action = DT::JS("function ( e, dt, node, config ) {
dt.page.len(-1);
dt.ajax.reload();
}")
)
)
)
)
)