add a length menu using layout on datatable 2.1.5

add a length menu using layout on datatable 2.1.5

SrViniciusSrVinicius Posts: 4Questions: 3Answers: 0

Hey guys! Everything fine?

I have a layout like that:

            layout: {
                topStart: {
                    buttons: [
                        {
                            extend: 'excel',
                            text: '<i class="fas fa-file-excel"></i> Excel',
                            attr: {
                                style: 'background-color: green; color: white;'
                            },
                            className: 'btn btn-success',
                            filename: function () {
                                const dataAtual = new Date();
                                const dia = dataAtual.getDate();
                                const mes = dataAtual.getMonth() + 1;
                                const diaFormatado = dia < 10 ? '0' + dia : dia;
                                const mesFormatado = mes < 10 ? '0' + mes : mes;
                                return Table + '-' + diaFormatado + '-' + mesFormatado + '-Example;
                            },
                        },
                    ],
                },
                topEnd: 'search',
                bottomStart: 'info',
                bottomEnd: 'paging'
            }

I can't add a length menu (inside and outsite the layout object). It's possible?

Answers

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Where do you want it to appear? If next to the search, you could do:

    topEnd: [ 'search', 'pageLength' ]
    

    If you want it on its own row above the table:

    top: 'pageLength'
    

    Or as a button next to the Excel one:

    buttons: [
      'pageLength',
      {
         extend: 'excel',
         ...
       }
    ]
    

    Or many more options. Have a look at this example.

    Allan

Sign In or Register to comment.