Reputation: 3972
How do I change the pagination number format of databales to another locale format, i.e. Arabic number format. I have read the datatables manual(https://www.datatables.net/examples/basic_init/language.html) and MDN(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat) but failed to find the solution.
Upvotes: 0
Views: 1567
Reputation: 85528
You have two choices (as far as I can tell) :
Alter the code, specifically the internal function pageButton
added to DataTable.ext.renderer
about line 14205 (v 1.10.7)
$.extend( true, DataTable.ext.renderer, {
pageButton: {
change the code about line 14258 from
default:
btnDisplay = button + 1;
btnClass = page === button ?
classes.sPageButtonActive : '';
break;
to
default:
btnDisplay = new Intl.NumberFormat('ar-EG').format(button + 1);
btnClass = page === button ?
classes.sPageButtonActive : '';
break;
Replace the rendered content upon the draw.dt
event
$('#example').on('draw.dt', function() {
$('.paginate_button').not('.previous, .next').each(function(i, a) {
var val = $(a).text();
val = new Intl.NumberFormat('ar-EG').format(val);
$(a).text(val);
})
});
Guess the pagination should look something like this
demo -> http://jsfiddle.net/hojpyahy/
Upvotes: 3
Reputation: 92
They have internationalisation plug-ins for changing locale format.
See this example using ajax , they changed language to german in this example : https://datatables.net/plug-ins/i18n/]1
Similarly, you can do for arabic.
Upvotes: 0