New line displaying pagination for Bootstrap datatable

I am currently utilizing the datatable feature with bootstrap version 4.3.1. The necessary CSS and JS files have been integrated as shown below:

<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.html5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.5.6/css/buttons.dataTables.min.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css" />

For exporting to Excel and other custom actions, I am using an HTML5 button.

The pagination feature is consistently displaying in a new line separate from the entries info in the footer section, illustrated here:

https://i.sstatic.net/4qNzC.png

Despite altering the sequence of CSS and JS files in various ways, the issue remains unresolved.

Here is the HTML code snippet used:

<div class="col-lg-8">
    <table id="example" class="table table-striped table-bordered" style="width:100%">
        <thead>
            <tr>
                <th>L</th>
                <th>W</th>
                <th>H</th>
                <th>W</th>
                <th>N</th>
                <th>Y</th>
                <th>P</th>
                <th>Pr</th>
            </tr>
        </thead>
        <tbody id="tbl">
            <tr>
                <td>12</td>
                <td>11</td>
                <td>14</td>
                <td>61</td>
                <td>1</td>
                <td>2019</td>
                <td>abc</td>
                <td>320800</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <th>L</th>
                <th>W</th>
                <th>H</th>
                <th>W</th>
                <th>N</th>
                <th>Y</th>
                <th>P</th>
                <th>Pr</th>
          </tr>
        </tfoot>
    </table>
</div>

And this is the JavaScript snippet being utilized:

$(document).ready(function () {
        for (var i = 0; i < 99; i++) {
            $('#tbl').append("<tr><td>" + i + "2</td><td>1" + i + "</td><td>" + i + "4</td><td>6" + i + "</td><td>1</td><td>2019</td><td>abc</td><td>32080" + i + "</td></tr>");
        }
        $('#example').DataTable({
            dom: 'Bfrtip',
            lengthMenu: [
               [10, 25, 50, -1],
               ['10 rows', '25 rows', '50 rows', 'Show all']
            ],
            buttons: [
            {
                text: 'Show Radar Chart',
                action: function (e, dt, node, config) {
                    $('#chartModal').modal('show');
                }
            },
            {
                extend: 'excelHtml5',
                text: 'Export to Excel'
            },
            "pageLength"
            ]
        });
    });

The loop seen above serves the purpose of populating the table by repeating data entries.

Answer №1

$(document).ready(function () {
        for (var i = 0; i < 99; i++) {
            $('#tbl').append("<tr><td>" + i + "2</td><td>1" + i + "</td><td>" + i + "4</td><td>6" + i + "</td><td>1</td><td>2019</td><td>abc</td><td>32080" + i + "</td></tr>");
        }
        $('#example').DataTable({
            dom: 'Bfrtip',
            lengthMenu: [
               [10, 25, 50, -1],
               ['10 rows', '25 rows', '50 rows', 'Show all']
            ],
            buttons: [
            {
                text: 'Show Radar Chart',
                action: function (e, dt, node, config) {
                    $('#chartModal').modal('show');
                }
            },
            {
                extend: 'excelHtml5',
                text: 'Export to Excel'
            },
            "pageLength"
            ]
        });
    });
#example_info, .dataTables_paginate {
    width: 50%;
    display: inline-block;
}

#example_info.dataTables_info {
    padding-top: 1.3em !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>

<script src="https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.html5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<link href="//cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.5.6/css/buttons.dataTables.min.css" />



<div class="col-lg-8">
    <table id="example" class="table table-striped table-bordered" style="width:100%">
        <thead>
            <tr>
                <th>L</th>
                <th>W</th>
                <th>H</th>
                <th>W</th>
                <th>N</th>
                <th>Y</th>
                <th>P</th>
                <th>Pr</th>
            </tr>
        </thead>
        <tbody id="tbl">
            <tr>
                <td>12</td>
                <td>11</td>
                <td>14</td>
                <td>61</td>
                <td>1</td>
                <td>2019</td>
                <td>abc</td>
                <td>320800</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <th>L</th>
                <th>W</th>
                <th>H</th>
                <th>W</th>
                <th>N</th>
                <th>Y</th>
                <th>P</th>
                <th>Pr</th>
          </tr>
        </tfoot>
    </table>
</div>

Here is a useful CSS snippet that will help you achieve the desired outcome.

#example_info, .dataTables_paginate {
    width: 50%;
    display: inline-block;
}
div#example_paginate {
    padding-top: 0.85em;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ensuring Radiobuttons are Selected on a Page After Clicking the Submit Button

Seeking assistance with this issue: I am working on a page that includes radio buttons: <label>Delivery type:</label> <input type="radio" name="delivery" value="7" class="delivery-item" id="del-type-7" onclick=""><label class="label" ...

Tips on embedding an HTML page within another HTML page by utilizing a custom directive in AngularJS

I am looking to utilize custom directives in order to insert one HTML page into another. How can I achieve this? The custom directive code is as follows: (here is the .js file) fbModule.directive('fbLogin', function(){ return { ...

What is the best way to design a grid consisting of 14 divs that span the entire width of the browser screen, incorporating dividers to separate different groups, utilizing a combination of html,

I am interested in creating a layout with two rows of divs that span the entire width of the screen, with a total of 14 divs in each row. These divs are fixed in size and grouped by color, with dividers separating each color group. I am hoping to achieve ...

Achieving Full Height for Parallel Columns Divs with Bootstrap - A How-To Guide

I am struggling with getting two divs in parallel to have full height. Even though I have the divs side by side, when I try to set their height:100%;, nothing happens. What CSS properties do I need to modify to achieve this? The goal is to create a cove ...

Is there a way to override a LESS variable inside a mixin?

Currently, I am incorporating LESS into one of my projects and I have a requirement to establish different color schemes for various users. The project involves developing a portal where the color scheme should change based on the type of user logging in. ...

Submitting forms with Ajax without reloading the page can cause errors in Internet Explorer

Simply put: Upon clicking the login button in Firefox, Chrome, or Safari, the form is submitted correctly, running a validation via ajax and opening a new page. However, in Internet Explorer (version less than 9), the submission attempts to post to the c ...

Creating an array dynamically in response to an AJAX call

Is there a way to dynamically create an array after receiving an AJAX response? Upon getting the AJAX response, the variable data.villages contains the data. To iterate over its values, the jQuery each function can be used: $.each(data.villages, functio ...

Spacing among values returned from the database

Seeking assistance with an issue in my code. I have written a piece of code that displays two columns from a database within a form. Unfortunately, the code is not allowing me to separate the two columns properly in the form. For example, if the name dis ...

Having trouble getting the background of the <span> element to function properly

So, here is the code I have been working on: echo "<span style='float:right; text-align:right; background-image:url('" . $icon_url . "') no-repeat top right; height:86px; width:86px; display:block;'>" . $curr_temp . "<br /> ...

How come JavaScript's history.back() method does not display form values?

I have been developing an HTML form that submits values to a PHP script. When encountering errors, I currently display the error message along with a link containing javascript:history.back(). In Chrome, the form reopens with all values retained from the ...

Are HTML tables a viable fix for the problem with ng-repeat?

Let's talk about a fictional dataset that mirrors tabular data found in Excel. function SU(name: String, data: Array<any>) { this.name = name, this.data = data }; function Month(month: String, year: String, goal: Number, projection: ...

Show a grid layout with adjustable sizing and elements centered in the middle

When dealing with a layout like the one below, how can we ensure that elements are centered within the wrap container? The margins around the elements should be flexible but at least 14px. .wrap{ display: grid; grid-template-columns: repeat(auto-fi ...

Customizing default styles in Bootstrap

Struggling to change the color and border in a Bootstrap nav bar with SCSS. Despite writing the code below, nothing seems to happen: .nav-link.active { color: #495057; background-color: chartreuse; border-color: black; } After inspecting the e ...

Can someone assist me in assigning a cookie value using the $.post() method?

Currently, I am running a script that utilizes jQuery's $.post to set a $_COOKIE['menu_item_id'] as the last insert id. Despite successfully setting the cookie value, I am facing an issue where I can't access this cookie in other parts ...

Receiving errors when sending XML via an AJAX request is a common issue

I'm encountering an issue with handling the response from a specific web service through my XML request. Despite the response appearing as expected in my browser's network tab, the error callback in my JavaScript code is triggering, treating it a ...

Why is it that $_POST is unable to fetch <img style="">?

Today, I encountered a problem with my textarea while creating it with the following code: <img style="padding-right:5px; width:200px; height:200px;" src="assets/images/logo.jpg"> After posting it to PHP using ajax, the PHP response appeared like t ...

Methods for retrieving the value of a hidden field with jquery

I am trying to retrieve the row id values from an accordion table using jQuery and checkboxes. I have set up a hidden value field to simplify the process, but I am encountering an issue where the hidden input id always reflects the last row value instead o ...

Using a local variable within quotes in Angular 4 (HTML) and utilizing ngFor

In my current project, I am utilizing Angular2-Collapsible. The objective is to display the details upon clicking a table row. Below is the code snippet provided. Specifically, if I add [detail]= "detail1", the collapsible-table-row-detail will appear when ...

When the page is launched, creating a rectangle at a precise location on the area map

I have successfully implemented the maphilight jquery plugin with hover and onclick features from here. It works great. Is there a way to automatically draw a rectangle on the areamap image at a defined position and size when the page loads, without requi ...

Utilizing PHP for Long Polling within AJAXcreateUrlEncodeProtect(chr(

Utilizing AJAX to refresh specific parts of a page without the need for constant reloading. However, I aim for the table to only refresh upon detecting changes (a concept known as long polling). Despite attempting to implement loops with break statements, ...