how can prevent change text on PageLenght Button?

how can prevent change text on PageLenght Button?

kitcatkitcat Posts: 12Questions: 1Answers: 0

hi

i use this code for my pageLenght button

    buttons: [
        {
            text:       '<i class="fa fa-list"></i>',
            titleAttr:  'page lenght',
            extend:     'pageLength',
        }]

and my page lenght button have an icon (not a text)
but when i click on sub buttons (for example 10 rows) page lenght icon changed to "10 rows"

how can i prevent change text on Page Lenght Button???

Replies

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @kitcat ,

    Yep, that text is being 'helpfully' changed - you can overwrite this though by listening on the length as in this example here.

    Cheers,

    Colin

  • kitcatkitcat Posts: 12Questions: 1Answers: 0

    hi
    thank for sample

    i need this code for titleAttr
    i cant use you sample for this button

            {
                text:       '<i class="fa fa-list"></i>',
                titleAttr:  'PAGE LENGTH',
                extend:     'pageLength',
            },
    
  • kitcatkitcat Posts: 12Questions: 1Answers: 0

    i change the button like this

            {
                name:       'pageLength',
                text:       '<i class="fa fa-list"></i>',
                titleAttr:  'PAGE LENGTH',
                extend:     'pageLength',
            },
    
  • kitcatkitcat Posts: 12Questions: 1Answers: 0

    and change the js code

        "initComplete": function(settings, json) {
            let mtable = $(`#${tbl_id}`).DataTable();
    
            mtable.on('buttons-action', function (e, buttonApi, dataTable, node, config) {
                table.buttons('pageLength:name').text('<i class="fa fa-list"></i>');
            });
        });
    

    thats work for me

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    Good point - thanks for raising that. I've added a bug to our db for this so I can allow for the text not being changed in future. Your workaround will continue to work though.

    Allan

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    Hi,

    Just to say that I've committed the fix for this now and it will be in the nightly version shortly and in the next release.

    Allan

This discussion has been closed.