0
votes

i have a problem with jquery datatable pagination (Server side processing).

For example i have a 24 records in database. The count is displaying correctly and total pagination also displaying correctly.

enter image description here

when i click on Next or 2nd page it displays records as per the display page length.enter image description here

Here 3rd Page last 4 records are not displayed.

Here my server side code is like this

$this->db->select("SQL_CALC_FOUND_ROWS user_id,user_name,email", FALSE);

        $this->db->from("users");
     $sTable="users";
        // Data set length after filtering
        $this->db->select('FOUND_ROWS() AS found_rows');
        $iFilteredTotal = $this->db->get('users')->row()->found_rows;

        // Total data set length
        $iTotal = $this->db->count_all($sTable);


        // Output
        $output = array(
            'sEcho' => intval($sEcho),
            'iTotalRecords' => $iTotal,
            'iTotalDisplayRecords' => $iFilteredTotal,
            'aaData' => array()
        );

Client side Code like this

$(document).ready(function () {
        $('#data_appraiser').dataTable({
            "bProcessing": true,
            "bServerSide": true,
            "oLanguage": {
                "sProcessing": imgsrc,
            },
            //"aaData": data.aaData,
             "iDisplayLength": 10,
             "aLengthMenu": [
                             [10, 25, 50],
                             [10, 25, 50] // change per page values here
                         ],
                "aaSorting": [[0, 'asc']],
                "sServerMethod": "POST",
                    "sAjaxSource": "appraiserlistajaxdata",

            "sPaginationType": "full_numbers"
            "aoColumns": [
                { "mData": "id" },
                { "mData": "appraiser_name" },
                { "mData": "user_name" }
               ....
            ]        
        });
    });

I checked with $iFilteredTotal total count.when the page changes the value is 20.If it is in 1st page the value is 24.i am unable to solve this problem. Sorry if my problem was weired.Could any one help me how to resolve this issue. Thanks

1
if you able to show this code on fiddle then only we can helpyouAnant Kumar Singh
What is your client side code to render the table?jonmrich
@jonmrich. Updated question with client side code.Please look at once.Krishna38
I'm not sure what the issue is that you're trying to fix. How many results are you looking to have per page? With only 24, you could easily show with just one page. If you want a specific number per page, let me know what that is.jonmrich

1 Answers

0
votes

You have to take start and length (like $_GET['start'])as the offset and limit respectively and apply in the query.