1

I am using Datatables (http://www.datatables.net) at one of my projects. The datatable opens in a Bootstrap Modal and I set the option that only 5 rows are visible on one page. That is working as it should.

Now I wanted to hide the dropdown box for display records and therefore I found the solution on this thread: StackoverFlow - Solution for hiding "Display Records"

My code looks like this now:

$(document).ready(function() {
$('#readnews').dataTable({
"iDisplayLength": 5,
"bPaginate": false,
"bLengthChange": false,
"bFilter": true,
"bInfo": false,
"bAutoWidth": false });

My Problem is now that this code is not working! If I use this code:

$(document).ready(function() {
$('#readnews').dataTable({
"iDisplayLength": 5 });

I can only see 5 rows at a page that is good. If I use this code:

$(document).ready(function() {
$('#readnews').dataTable({
    "bPaginate": false,
    "bLengthChange": false,
    "bFilter": true,
    "bInfo": false,
    "bAutoWidth": false });
});

I can see that the "Display Records" is hidden but I am not able to use both options (hide "Display Records" and only show 5 recors per page) at once.

Can someone tell me what I am doing wrong? What should my code look like? I do not know what I am doing wrong.

Thanks in advance, Chris

Community
  • 1
  • 1
Christoph C.
  • 840
  • 2
  • 22
  • 38

1 Answers1

1

I Means

 $(document).ready(function () {
            $('#readnews').DataTable({
                 "fnDrawCallback": function (oSettings) { 
                    if ($('#readnews tr').length < 5) {
                        $('.dataTables_paginate').hide();
                    }
                },

                 "bLengthChange": false,
                 "bFilter": true,
                 "bInfo": false,
                 "bAutoWidth": false,
                 "iDisplayLength": 5,

            });
        });
Abrar Khan
  • 175
  • 10
  • Thanks for your help! Looks good now but problem is, that now I have 6 news and only 5 are visible and I do not have the function to move to second page at the bottom. See here: http://easycaptures.com/fs/uploaded/1022/1315137953.png! So if I have 30 news than I need the option to see 5 news per page and can move to 2nd, 3rd and so on page to see all other news. – Christoph C. Nov 18 '15 at 13:24