Page and start parameter is always 0 - server side

Page and start parameter is always 0 - server side

FeuFeu Posts: 3Questions: 0Answers: 0

I have a problem, when the page loads the start parameter is 0. But when click to the second page (previous or other page), i see the first page again and the active button is 1 don't change to 2 pager or other page.

The code below, variable info i see page and start with value 0.

 "data": function (d) {
                    var info = $('#btable').DataTable().page.info();
                    d.DateI = $('#min').val();
                    d.DateF = $('#max').val();

                    return d;
                },

Backend paramenter,

int start = Convert.ToInt32(Request["start"]);

Json response is,

"{"data":[....],"draw":9,"recordsTotal":180,"recordsFiltered":180,"recordsYes":76,"recordsNo":32,"recordsNot":72,"dateMax":"11/05/2018","dateMin":"11/05/2018"}"

table = $('#btable').DataTable({
            "responsive": true,
            "dom": "<'row'<'col-6'l><'col-6'f>><'row'<'col-12'rt>><'row'<'col-6'i><'col-5'p>>",
            "paging": true,
            "displayStart": 0,
            "pageLength":10,
            "processing": true,
            "serverSide": true,
            "ajax": {
                "url": "/Admin/GetAll",
               "type": 'POST',
                "datatype": "json",
                "data": function (d) {
                    d.DateI = $('#min').val();
                    d.DateF = $('#max').val();

                    return d;
                },
                "dataFilter": function (res) {
                    var result = JSON.parse(res);
                    if (result.Max === result.Min) {
                        $('#RangeDate').text("");
                        $('#RangeDate').append('Date: ' + result.Max);
                    } else {
                        $('#RangeDate').text("");
                        $('#RangeDate').append('Date ' + result.Min + " and " + result.Max);
                    }
                    return res;
                }
            },
            "createdRow": function (row, data, dataIndex) {
                if (data.Status === 'No') {
                    $(row).addClass('rowNo);
                }
                else if (data.Status === 'Yes') {
                    $(row).addClass('rowYes');
                } else {
                    $(row).addClass('rowNot');
                }
            },
            columnDefs: [
                { "name": "Id", "targets": 0 },
                { "name": "Name", "targets": 1 },
                { "name": "Status", "targets": 2 },
                { "name": "ExecutionDate", "targets": 3 }
            ],
            columns: [
                {
                    data: "Id"
                },
                { data: "Name" },
                { data: "Status" },
                {
                    data: "ExecutionDate",
                    format: 'dd/mm/YYYY',
                    "render": function (data) {
                        if (data === null) {
                            return '';
                        } else {
                            //Replace date format
                        }
                    }
                }

            ], initComplete: function () {

                var columnDate = this.api().column(3);

                $('#min').change(function () {
                    var val = $(this).val();
                    columnDate.search(val, true, false).draw();
                });
                $('#max').change(function () {
                    var val = $(this).val();
                    columnDate.search(val, true, false).draw();
                });
            }
        });

what is wrong?

thanks,
feups

Replies

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    when the page loads the start parameter is 0. But when click to the second page (previous or other page), i see the first page again and the active button is 1 don't change to 2 pager or other page.

    When click to the next page what is the start parameter? Are you using the browser's network tools to look at the communication between the client and server?

    When you look at the response is the data for the first page or the second page?

    Is the Draw parameter returned from the server script the same as what is in the request?

    Kevin

  • FeuFeu Posts: 3Questions: 0Answers: 0

    when I click the next page the start value is 0, yes i use the network tools.

    the data on the first page or when click te second page is the same, only changed draw value.

    But when i click on the second page, i don't go to the second page with values the first page. I stay the first page.

    Feu

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    The server side examples here work properly:
    https://datatables.net/examples/server_side/index.html

    I don't see anything that stands out as an issue. Can you post a link to your page for troubleshooting?

    Kevin

  • FeuFeu Posts: 3Questions: 0Answers: 0

    i did not remember to mention but the code working in localhost with iis server. but when i do deploy to the web server and test the website the pagination not work there.

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    the code working in localhost with iis server. but when i do deploy to the web server and test the website the pagination not work there.

    Without a link to your non-working page or a test case showing the issue its nearly impossible to help troubleshoot.

    Kevin

This discussion has been closed.