Pagination problems or rows in the table are not all

Pagination problems or rows in the table are not all

localhost1localhost1 Posts: 5Questions: 2Answers: 0

I fill the table like this, using php (example)

        <? foreach($array as $k => $v){?>
        <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
        </tr>
        <?}?>

After processing PHP, should have 250 rows in the table.
But when I initialize DataTables, I only see: Showing 1 to 10 of 20 entries
It should be 25 pages, but displayed only 2 pages

why is this happening?

        $('#mytable').DataTable({
                    responsive: true,
                    "ordering": true,
                    dom: 'Bfrtip',
                    "order": [[ 6, "desc" ]],
                    "columnDefs": [ {
                        "orderable": false,
                        "targets": 10
                    }],
                    buttons: datatablesButtons('test', 'test'),
                    initComplete: function () {
                        this.api().columns().every( function ( i ) {
                            var column = this;
                            var to_search = $(column.footer()).attr('t-search');
                            var t_data = $(column.footer()).attr('t-data');
                            var text = $(column.footer()).text();
                            var classes = 'form-control input-sm';
                            var styles = 'margin: 0 auto;width:90%;display: block;';
                            var data_id = 'data_'+i;
                            var list = 'list_'+i;
                            var $object_append = $(column.footer()).empty();
                            var group = '<div class="inner-addon left-addon"><i class="fas fa-search"></i></div>';

                            if ( to_search !== 'false' ) {
                                $object_append.append(group);
                                $obj_append = $object_append.find('div');
                                $('<input list="'+list+'" class="'+classes+'" style="'+styles+'" placeholder="'+text+'">')
                                    .appendTo( $obj_append )
                                    .on( 'change', function () {
                                        var val = $(this).val();
                                        column.search( val ).draw();
                                    } );

                                    var options = $obj_append.append('<datalist id="'+list+'"></datalist>');
                                    column.data().unique().sort().each( function ( d, j ) {
                                        d = stripHtml( d );
                                            var val = $.fn.dataTable.util.escapeRegex(d);
                                            if( badStr(d) )
                                            d = d ? '^'+d+'$' : '', true, false;
                                        $('datalist[id="'+list+'"]').append( '<option value="'+d+'">'+d+'</option>' )
                                    } ); 
                            }
                        } );
                    }
            });

Answers

  • localhost1localhost1 Posts: 5Questions: 2Answers: 0

    PS: I don't use Ajax, because don't need it

  • localhost1localhost1 Posts: 5Questions: 2Answers: 0

    I apologize, the topic can be closed. The problem was my carelessness, it turned out there were 20 values in array.

This discussion has been closed.