Hari Subramaniam
Hari Subramaniam

Reputation: 1876

How to display numbers only in pagination of jQuery DataTables

I am pretty new to jQuery DataTables. I am looking out for a pagination where I display only the numbers and not options like Previous, Next, etc. I tried this but it didn't work.

$("#myCsps").dataTable({
  "bFilter": false,
  "bInfo": true,
  "bProcessing": true,
  "sPaginationType": "bootstrap",
  "asStripClasses": null,
  "oLanguage": {
    "sInfo": "Total CSPs: _TOTAL_",
    "oPaginate": {
      "sNext": "",
      "sLast": "",
      "sFirst": null,
      "sPrevious": null
    }
  },
  //oSearch: { "sSearch": "Type here...", "bRegex": false, "bSmart": false },
  "bLengthChange": false,
  "aaData": data,
  "aoColumns": columnSettings,
  "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {

    $(nRow).children().each(function(index, td) {

      if (index == 7) {

        if ($(td).html() === "Schedule0") {
          $(td).css("background-color", "#078DC6");
        } else if ($(td).html() === "Schedule1") {
          $(td).css("background-color", "#FFDE00");
        } else if ($(td).html() === "Schedule2") {
          $(td).css("background-color", "#06B33A");
        } else if ($(td).html() === "Schedule3") {
          $(td).css("background-color", "#FF3229");
        } else {
          $(td).css("background-color", "#FF3229");
        }


      }
    });
    return nRow;
  }
});

Upvotes: 1

Views: 11960

Answers (2)

Gyrocode.com
Gyrocode.com

Reputation: 58880

Starting jQuery DataTables 1.10.8 it is possible to use pagingType: 'numbers' to display page numbers only.

var table = $('#example').DataTable({
    pagingType: 'numbers'
});

See this example for code and demonstration.

Upvotes: 1

Anuruddha
Anuruddha

Reputation: 3245

You can use pagination plugin Ellipses.You might have to do little bit of customization as well,but it's pretty straight forward.

Here is a link to a customized version of ellipses plugin gits.

Upvotes: 0

Related Questions