Search code examples
jquerydatatablesdatatables-1.10

DataTables pagination plugin for input not working


I am trying to use input plugin of DataTables for the pagination. I have all three jar files loaded - jQuery1.11.1, dataTables1.10 and input.js. But still I am getting

TypeError: $.fn.dataTableExt is undefined 

and

TypeError: plugin is undefined

errors.

Do I have to include any other jar? In some old post I saw plugin.jar being loaded but in DataTables plugin page itself there is no mention of this JAR.

DataTables Initialization code

var table = $jq11('#openCasesTable').dataTable({
    "ajax": someUrl,
    "aoColumnDefs": [
        { "bSortable": false, "aTargets": [0, 6, 7] }
    ],
    "columns": [
        { 
            "data": null,
            "render": function(data, type, row, meta) {
                ...
            }
        },
        ...
    ],
    "deferRender": true,
    "dom": 'l<"#removeButtonDiv.removeButton">rtip',
    "filter": false,
    "initComplete": function(settings, json) {
        $('#removeButtonDiv').html('<input id="removeButton" type="button" value="Remove"  style="float:right; height: 25px;" disabled />');
    },
    "lengthMenu": [ [20, 40, 60, 80, 100], [20, 40, 60, 80, 100] ],
    "language": {
        "emptyTable": "No data to list",
        "infoFiltered": " "
    },
    "order": [[4, "desc"]],
    "processing": true,
    "drawCallback": function( settings ) {
        $.each(selected, function(index, value){
            $('#'+value).attr("checked", "checked");
        });
    },
    "serverSide": true,
    "sPaginationType": "input"
});

Solution

  • From dataTable 1.10, they changed pagination structure. Now they use "paging" (Boolean), "pagingType" (String) properties, and it seems they changed the pagination plugin structure also. As a result, every pagination plugin would be not working on 1.10. You may use dataTable 1.9.

    New pagination options : http://datatables.net/reference/option/pagingType

    Pagination plugin page under construction : http://datatables.net/manual/plug-ins/paging

    They provide full, simple, full_numbers, and simple_numbers as default options. If you want to use input pagination, you can download dataTable 1.9 in their github or try to make own backward compatibility logic like they provided in upgrade section.

    $(document).ready(function() {
        $('#example').dataTable( {
          "pagingType": "full_numbers"
        } );
    } );