lengthMenu: Option Not Working

lengthMenu: Option Not Working

zgoforthzgoforth Posts: 493Questions: 98Answers: 2

Hello, I have created a DataTable that is currently filled with 15 records, and I want to figure out how to get them all on to one page. I have researched the lengthMenu option and nothing happens. I will add the part of my initialization where I have included it.

$(document).ready(function() {
 var collapsedGroups = {};
    
  var table = $('#myTable').DataTable( {
    "lengthChange": true,
    "lengthMenu": [ 10, 25, 50, 75, 100 ],
    "columns": [
      { "data": "Program", visible: false },
      { "data": "Deliverable" },
      { "data": "To" },
      { "data": "Date" },
      { "data": "Approved" },
      { "data": "Notes" }
    ],
    
    dom: 'Bfrtip',
    buttons: [
        'copy','csv','excel','pdf','print'
    ],
    orderFixed: [0, 'asc'], 
    rowGroup: {
            dataSrc: 'Program',
            startRender: function (rows,group){
                var collapsed = !!collapsedGroups[group];
              
              rows.nodes().each(function(r) {
                r.style.display = collapsed ? 'none' : '';
              });
              //Add category name to the <tr>.
              return $('<tr/>')
                .append('<td colspan="8">' + group + ' (' + rows.count() + ')</td>')
                .attr('data-name', group)
                .toggleClass('collapsed', collapsed);
            
            }
            
        }
  } );

Replies

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923
    edited September 2020

    dom: 'Bfrtip',

    Please see this FAQ for the solution.

    Kevin

This discussion has been closed.