15

How do you remove the 'Show Entries' info below a datatable from the DT package in R?

I know about the solutions below, but I cannot figure out how to make them work when using them with rmarkdown.

[1] How to hide "Showing 1 of N Entries" with the dataTables.js library

[2] how to disable show entries property in jquery datatable

I have tried to add the below to the css file for rmarkdown, but that does not seem to work.

$('#example').dataTable({ 
"bInfo": false
});
Community
  • 1
  • 1
Hans-Peter Schrei
  • 432
  • 1
  • 6
  • 14

2 Answers2

24

You need to add options = list(lengthChange = FALSE) when you call the function.

For example, if you're using it in a shiny application, you would include something like this in the ui.R part (where you want your table to show up):

dataTableOutput("myTable")

and something like this in the server.R part:

output$myTable <- renderDataTable(df, 
                  options = list(pageLength = 15, lengthChange = FALSE),
                  rownames= FALSE)

where df is the dataframe you are displaying in the table. (Note that I included a few other options for illustration purposes. Confusingly enough, some of these options, like rownames go outside that options list.) All the available options you can include are here.

Vlad
  • 912
  • 9
  • 9
5

I don't know about R. but you can see on this link that you need to use the following code

$('#example').dataTable( {
  "lengthChange": false
} );

This code has to be inside your javascript file not the css.

laviku
  • 531
  • 12
  • 32