Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove 'Show Entries' in datatable

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
});
like image 307
castle Avatar asked Feb 02 '16 15:02

castle


2 Answers

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.

like image 143
Vlad Avatar answered Sep 22 '22 05:09

Vlad


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.

like image 40
laviku Avatar answered Sep 22 '22 05:09

laviku