Pagination and Display Length not working for Datatable (1.9.4)

Pagination and Display Length not working for Datatable (1.9.4)

bmobmo Posts: 1Questions: 1Answers: 0
edited November 2016 in Free community support

Hi! I've scoured the internet to see if anyone else has come across my problem exactly. I've attempted several solutions such as adding iDisplayLength and sPaginationType, however I cannot seem to get it working at all. When the datatable loads, all entries are shown (even though the default show option is 10 in the dropdown). Using this dropdown does not change the dataset at all. Because of this, pagination also does not work.
Here is the code for the datatable:

$(document).ready(function () {
                    $datatable = $("#tblWeightPedometer").dataTable({
                        "bJQueryUI": true,
                        "sPaginationType": "full_numbers",
                        "bServerSide": true,
                        "iDisplayLength" : 10,
                        "sAjaxSource": "@Url.Action("AjaxHandlerPedometerWeight")",
                        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
                        "aoColumns": [
                            {
                                "sName": "ID",
                                "mRender": function (data, type, row) {
                                    return $("#row-commands-id").html()
                                        .replace("id_to_replace", row[0])
                                        .replace("id_to_replace", row[0]);
                                }
                            },
                            {
                                "sName": "OwnerId",
                                "mRender": function (data, type, row) {
                                    return $("#row-commands-ownerid").html()
                                        .replace("OwnerUsername_to_replace", row[5])
                                        .replace("OwnerId_to_replace", row[1]);
                                }
                            },
                            {
                                "sName": "Weight",
                                "mRender": function (data, type, row) {
                                    return $("#row-commands-weight").html()
                                        .replace("weight_to_replace", row[3]);
                                }
                            },
                            {
                                "sName": "Steps",
                                "mRender": function (data, type, row) {
                                    return $("#row-commands-steps").html()
                                        .replace("completed_steps", row[2]);
                                }
                            },
                            {
                                "sName": "Date",
                                "mRender": function (data, type, row) {
                                    return $("#row-commands-date").html()
                                        .replace("date_to_replace", row[4]);
                                }
                            },
                            {
                                "sName": "Remove",
                                "mRender": function (data, type, row) {
                                    return $("#row-commands-removeWeightPedometerEntry").html()
                                        .replace("id_to_remove", row[0]);
                                }
                            }
                        ]
                    });

Another issue is at the bottom of the table it says:
Showing 0 to 0 of 0 entries (filtered from 14 total entries)
Could this also be related to the problem?

Thanks if anyone can help out, I would just like basic filtering (10,25,50,all) to work, along with pagination.

Answers

  • allanallan Posts: 63,819Questions: 1Answers: 10,517 Site admin
    edited November 2016

    You are using server-side processing, so you would you need the server to return the data in the legacy format.

    I'd suggest updating to 1.10.x btw. 1.9 is no longer supported.

    Allan

This discussion has been closed.