ALL LengthMenu in DataTable is not working

ALL LengthMenu in DataTable is not working

Asif ShaikihAsif Shaikih Posts: 6Questions: 1Answers: 0
edited January 2018 in Free community support

i have used "ALL" option of a DataTable LengthMenu but it returns all Record excluding the last record

"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]

please help for the same
thank you..

Answers

  • Asif ShaikihAsif Shaikih Posts: 6Questions: 1Answers: 0

    please help for the same
    thank you

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Happy to a test a look at a test case showing the issue.

    Allan

  • Asif ShaikihAsif Shaikih Posts: 6Questions: 1Answers: 0

    this is my code

    var table = $('#certificate_management').DataTable({
    "bProcessing": true,
    "dom": '<"top_tabel"Bpl>rt<"clear">',
    buttons: [
    {
    extend: 'csv',
    footer: false,
    exportOptions: {
    columns: [0, 1, 2, 3, 4, 5, 6, 9, 10]
    }
    }
    ],
    "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
    "scrollY": "510px",
    "scrollCollapse": false,
    "responsive": true,
    'serverSide': true,
    "ordering": true,
    "bInfo": false,
    language: {
    "sSearch": "",
    "url": ADMIN_URL + "assets/js/swedish.json"
    },
    "fnDrawCallback": function () {
    $('.dataTables_length select').addClass('lenthcls');
    $('.lenthcls').select2({minimumResultsForSearch: -1});
    $('input[type="search"]').css('display', 'none');
    },
    'order': [11, 'desc'],
    'columnDefs': [{
    "targets": 7, // your case first column
    "className": "text-center c"
    },
    {
    "targets": 8,
    "className": "text-center"
    },
    {
    "targets": [9, 10, 11],
    "visible": false,
    "searchable": false
    }],
    "aoColumns": [
    null,
    null,
    {"bSearchable": false},
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null
    ],
    "ajax": $.fn.DataTable.pipeline({
    url: ADMIN_URL + "Certificate/lists",
    //pages: 1 // number of pages to cache
    })
    });

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    You have server-side processing enabled, so the issue will be in the server-side script. Is it setup to access a page length of -1 to return all entries?

    Allan

  • Asif ShaikihAsif Shaikih Posts: 6Questions: 1Answers: 0

    The Code In DataTables.php

    private function get_paging() {
    $iStart = $this->ci->input->post('start');
    $iLength = $this->ci->input->post('length');

        if ($iLength != '' && $iLength != '-1')
            $this->ci->db->limit($iLength, ($iStart) ? $iStart : 0);
    }
    
  • Asif ShaikihAsif Shaikih Posts: 6Questions: 1Answers: 0

    i had see the Ajax respond which give me an All the Record
    so i think may be the server side is ok.

  • Asif ShaikihAsif Shaikih Posts: 6Questions: 1Answers: 0

    you want to see the DataTables.php
    may i send you ?

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    I'm afraid I can't debug your PHP - however, if all records expect form the last one is being returned, it would be worth outputting the SQL that your script is generating and making sure that there is no OFFSET or LIMIT in it.

    Allan

  • ASIF4394ASIF4394 Posts: 6Questions: 1Answers: 0

    hi....
    When i filter a Record and shown in Datatable the record is Shown in inproper format
    please help for the same.
    thanks in advance
    .

    i want like this

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Asif4394, you posted your last comment on two other threads, please ensure you only ask a question once! I'd say the filter question is separate from the OP here, so let's use the other thread for your filter problems.

This discussion has been closed.