0

I am using JQuery data tables to show the contents of a grid. By Default the "Show entries" dropdown has (10,25,50,100) in it, and on load it renders 10 records per page. I need it to have (100,250,All) and default rendered number of records per pages should be 100. How can I achieve that ?

This is my function.

<script type="text/javascript">
$(document).ready(function () {
    RMDPP.ViewDataSet.Init();
    $('.sortabletable').dataTable({
        columnDefs: [{ orderable: false, "targets": -1 }, { orderable: false, "targets": 1 }] /*1st and last column will not be sorted*/
    });
});

1 Answers1

1

Use pageLength and lengthMenu options to change the initial page length and change the options in the page length menu.

For example:

var table = $('#example').DataTable({
    'lengthMenu': [ [100, 250, -1], [100, 250, 'All'] ],
    'pageLength': 100
    // ... skipped ...
});

See this example for code and demonstration.

Gyrocode.com
  • 57,606
  • 14
  • 150
  • 185