Prashant Shah
Prashant Shah

Reputation: 11

DataTable with custom pagination text

I used the code below to change the default option of jQuery DataTables to show 12,24,36,48 records per page instead of the default 10,25,50,100 records.

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

Is there a way I can display the dropdown option text as "12 cell phones, 24 cell phones, 36 cell phones, 48 cell phones"?

Upvotes: 1

Views: 855

Answers (1)

Captain Red
Captain Red

Reputation: 1171

The option you are looking for is "aLengthMenu". You can achieve this as:

$(document).ready( function(){
    $('#table').dataTable({
      "aLengthMenu": [[12, 24, 36, 48], ["12 Cell Phones Per Page", "24 Cell Phones Per Page", "36 Cell Phones Per Page", "48 Cell Phones Per Page"]]
    });
});

Upvotes: 1

Related Questions