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
});
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With