lengthMenu not setting default value

lengthMenu not setting default value

YinkaYinka Posts: 19Questions: 8Answers: 0

Could you please help. The lengthMenu is not setting default value in my table. I tried idisplayLength too but same thing.

<script> $(document).ready( function () {
    
    


    var otable=$('#listing').DataTable({
        "orderCellsTop":true,
        "idisplayLength":6,
        
            "lengthMenu":[[6, 25, 50, -1], [6, 25, 50, "All"]],
             
        
         
            
        

        
        
    });

I included the following cdn in my file:

<link rel="stylesheet" type="text/css" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href = "https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap.min.css">

<link rel="stylesheet" type="text/css" href = "https://cdn.datatables.net/responsive/2.2.3/css/responsive.bootstrap.min.css">





This question has an accepted answers - jump to answer

Answers

  • YinkaYinka Posts: 19Questions: 8Answers: 0
    edited October 2019
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap.min.js"></script>
    
    <script type="text/javascript" src="https://cdn.datatables.net/fixedheader/3.1.5/js/dataTables.fixedHeader.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.3/js/responsive.bootstrap.min.js"></script>
    
    
  • colincolin Posts: 9,003Questions: 0Answers: 1,501
    Answer ✓

    Hi @Yinka ,

    It works OK for me, see here. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

  • YinkaYinka Posts: 19Questions: 8Answers: 0

    Thank you Colin for your timely response. I must be missing something out in the HTML. it is dynamically generated with many functions within. My task was to apply datatable to the existing table.

    Regards,

    Yinka

  • YinkaYinka Posts: 19Questions: 8Answers: 0

    Just to add how I resolved this. I found out through the developer tool a style not define error. With the solutions that I found on stack overflow, I removed the colspan in my table head and call datatable method. I then use the jquery attr method to return the colspan and rowspan .

Sign In or Register to comment.