Length Change not working

Length Change not working

CountyCounty Posts: 10Questions: 4Answers: 0
edited September 2018 in Free community support

Hey all, I've read over the documentation regarding the length change, but I simply cannot get it to work with my script below since the length change stays as default. Does anyone know how to fix it please? I would like to only display 10 records per page. If that's not possible, I'd like to disable the length change all together. Thanks! :)

<script type="text/javascript" charset="utf8">
            $(document).ready(function(){
                
        $('#myTable').dataTable( { "sPaginationType": "full_numbers"} );
        $("#myTable").css("font-size", 14);
        $("myTable").dataTable("lengthChange", 10);
      

    });
   
</script>

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    edited September 2018

    lengthChange values are true or false. I suspect you need lengthMenu.

  • colincolin Posts: 15,236Questions: 1Answers: 2,598

    Hi @County ,

    As @tangerine says, lengthChange is a boolean, you probably want lengthMenu.

    Also, you're initialising the table twice - first on line 4, then again on line 6 - with different options. You're probably getting a console error saying warning against this. Just put all the options for the table in a single initialiser, i.e:

            $('#myTable').dataTable( {
                pagingType: "full_numbers",
                lengthChange: false
           });
            $("#myTable").css("font-size", 14);
    

    Cheers,

    Colin

This discussion has been closed.