How do you update the Page length button caption?

How do you update the Page length button caption?

yishayhyishayh Posts: 108Questions: 17Answers: 0

Hi,

regarding this
https://datatables.net/extensions/buttons/examples/initialisation/pageLength.html

How can you update the button caption?
I tried both
"lengthMenu": [
[10,20,50,100,200,400],
[10,20,50,100,200,400]
],
"sLengthMenu": "MENU",
and
"lengthMenu": 'Display <select>'+
'<option value="10">10</option>'+
'<option value="20">20</option>'+
'<option value="30">30</option>'+
'<option value="40">40</option>'+
'<option value="50">50</option>'+
'<option value="-1">All</option>'+
'</select> records'

The first worked button-wise, but the caption didn't changed (showed "Show 10 rows").
The second just didn't worked.

Thanks,
Yishay

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    Use the text option of the pageLength button type.

    Allan

  • yishayhyishayh Posts: 108Questions: 17Answers: 0
    edited May 2016

    Hi Allan,

    I'm sorry, I forgot to mention this in my previous post, we already done that:

              {
                text:$translate.instant(''),
                extend: "pageLength",
                className: "fa fa-arrows-v",
              }
    

    Thanks,
    Yishay

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    $translate.instant('')

    Does that resolve to be an empty string? If so, that might be the issue.

    Allan

  • yishayhyishayh Posts: 108Questions: 17Answers: 0

    Hi Allan,

    that seems to be the issue.
    It still seems that both ways defined in the documentation doesn't work (these are the only way to show on the button the number of records selected).

    Thanks,
    Yishay

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    Answer ✓

    It looks like there is a bug that the button text is overridden when the value is changed. It work for me on first load, but not after a change. That is a bug that will need to be addressed.

    Allan

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    Using the language.buttons.pageLength option works:

            language: {
                buttons: {
                    pageLength: '%d'
                }
            }
    

    Example: http://live.datatables.net/siqegube/1/edit .

    Allan

  • yishayhyishayh Posts: 108Questions: 17Answers: 0

    Works like a charm.
    Thanks!
    Yishay

This discussion has been closed.