3

My app is using angular datatables. Pagination consists of

[First] [Previous] [1] [Next] [Last]

I'd like to change this to shorter strings, such as

|< < 1 > >|

I'm sure this is possible, but I cannot find any reference to it in the docs.

This, among other places, is where I've been looking:

http://l-lin.github.io/angular-datatables/#/changeOptions https://datatables.net/examples/basic_init/alt_pagination.html

Here is a snippet of the HTML and controller:

<table class="table table-sortable table-hover table-checkable order-column"
    id="package-table"
    datatable="ng"   
    dt-options="manifestVm.dtPackageOptions"
    dt-column-defs="manifestVm.dtPackageColumnDefs">



vm.dtPackageOptions = DTOptionsBuilder.newOptions()
    .withPaginationType('full_numbers')
    .withDisplayLength(10)
    .withBootstrap();

vm.dtPackageColumnDefs = [
    DTColumnDefBuilder.newColumnDef(0),
    DTColumnDefBuilder.newColumnDef(1),
    DTColumnDefBuilder.newColumnDef(2)
];
DaveC426913
  • 2,012
  • 6
  • 35
  • 63

3 Answers3

4

I think you can edit the language settings.

The default language object looks like:

{
"decimal":        "",
"emptyTable":     "No data available in table",
"info":           "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty":      "Showing 0 to 0 of 0 entries",
"infoFiltered":   "(filtered from _MAX_ total entries)",
"infoPostFix":    "",
"thousands":      ",",
"lengthMenu":     "Show _MENU_ entries",
"loadingRecords": "Loading...",
"processing":     "Processing...",
"search":         "Search:",
"zeroRecords":    "No matching records found",
"paginate": {
    "first":      "First",
    "last":       "Last",
    "next":       "Next",
    "previous":   "Previous"
},
"aria": {
    "sortAscending":  ": activate to sort column ascending",
    "sortDescending": ": activate to sort column descending"
}
}

So to add the styling you want, change it to:

    {
"decimal":        "",
"emptyTable":     "No data available in table",
"info":           "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty":      "Showing 0 to 0 of 0 entries",
"infoFiltered":   "(filtered from _MAX_ total entries)",
"infoPostFix":    "",
"thousands":      ",",
"lengthMenu":     "Show _MENU_ entries",
"loadingRecords": "Loading...",
"processing":     "Processing...",
"search":         "Search:",
"zeroRecords":    "No matching records found",
"paginate": {
    "first":      "<<",
    "last":       ">>",
    "next":       ">",
    "previous":   "<"
},
"aria": {
    "sortAscending":  ": activate to sort column ascending",
    "sortDescending": ": activate to sort column descending"
    }
}

You are concerned with: language.paginate.first, language.paginate.last, language.paginate.next and language.paginate.previous.

Here is an example of how to change 'first' when creating the datatable.

$('#example').dataTable( {
  "language": {
    "paginate": {
      "first": "First page"
    }
  }
} );

Here is also a link to a related Stack Overflow answer that also talks about editing the language object settings

Community
  • 1
  • 1
  • That's a good example for jQuery, but not applicable for Angular Datatables – Michael Westcott Oct 06 '16 at 06:48
  • @Michael Westcott With a little research you can figure it out how to use this with angular datatables. Here. $scope.dtOptions = DTOptionsBuilder.newOptions() .withLanguage({ "info": "Showing _START_ to _END_ of _TOTAL_", "lengthMenu": "Show _MENU_" }); – Exzile Feb 21 '17 at 20:00
2

Late Answer. but it may be useful for someone.

vm.dtPackageOptions = DTOptionsBuilder.newOptions()
    .withPaginationType('full_numbers')
    .withDisplayLength(10)
    .withBootstrap();
    .withLanguage({
                "processing": "Processing...",
                "loadingRecords": "Loading...",
                "paginate": {
                    "first": '<i class="fa fa-fast-backward" aria-hidden="true"></i>',
                    "last": '<i class="fa fa-fast-forward" aria-hidden="true"></i>',
                    "next": '<i class="fa fa-step-forward large" aria-hidden="true"></i>',
                    "previous": '<i class="fa fa-step-backward" aria-hidden="true"></i>'
                }
            })
Kalyan
  • 1,200
  • 1
  • 11
  • 23
1

There is api for it: DTOptions > withLanguage(oLanguage)

you can check it out here. Go to DTOptionsBuilder tab and search for withLanguage(oLanguage) and then oPaginate.

Kishor Sharma
  • 599
  • 8
  • 15