Some problem with "lengthMenu" ...

Some problem with "lengthMenu" ...

rabitonarabitona Posts: 1Questions: 0Answers: 0
edited April 2016 in Free community support

Hello ! I can active the drop menu to change the number of issues on my page.

My code :

<script type="text/javascript">
$(document).ready(function() {
    $('#resultats').DataTable( {
        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        dom: 'Bfrtip',
        buttons: [
            'copy', 'csv', 'excel'
        ],
         initComplete: function () {
            <?php if(isset($_SESSION['user'])){?>
            this.api().columns('th:gt(1)').every( function () {
            <?php }else{ ?>
            this.api().columns('th:gt(0)').every( function () {
            <?php } ?>
                var column = this;
                var select = $('<select><option value=""></option></select>')
                    .appendTo( $(column.footer()).empty() )
                    .on( 'change', function () {
                        var val = $.fn.dataTable.util.escapeRegex(
                            $(this).val()
                        );
 
                        column
                            .search( val ? '^'+val+'$' : '', true, false )
                            .draw();
                    } );
 
                column.data().unique().sort().each( function ( d, j ) {
                    select.append( '<option value="'+d+'">'+d+'</option>' )
                } );
            } );
        }
        
    } );
} );
</script>

Somebody can explain me why ? :)
Thx ! :D

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Replies

  • allanallan Posts: 63,791Questions: 1Answers: 10,513 Site admin

    Do you mean you can't activate the dropdown? If so, please link to a page showing the issue, per the forum rules, so it can be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

This discussion has been closed.