Fixed Header isn't working for me - Code and photos inside here.

Fixed Header isn't working for me - Code and photos inside here.

logan3043logan3043 Posts: 14Questions: 3Answers: 0

I went through the download builder and did include the fixed header. I'm using cdn to insert the libs.
Thank you for your assistance.

I'd like the show entries, search bar and thead to sticky-top.

This is before scrolling the table down:

This is after scrolling the table down:

Here is my table structure:

<table id="customers" class="table table-hover">
                            <thead>
                            <tr>
                                <th>Name</th>
                                <th>Address</th>
                                <th>City</th>
                                <th>State</th>
                                <th>Zip</th>
                                <th>Phone</th>
                                <th>E-mail</th>
                                <th>Delete</th>
                            </tr>
                            </thead>
                            <tbody id="table_body">
                            @if($customer_list)
                                @foreach($customer_list as $customer)
                                    <tr href="#">
                                        <td>
                                            <a href="#"
                                               class="nav-link font-weight-bold">{!! $customer->first_name . ' ' . $customer->last_name !!}</a>
                                        </td>
                                        <td>
                                            <span class="table-span">{!! $customer->address !!}</span>
                                        </td>
                                        <td>
                                            <span class="table-span">{!! $customer->city !!}</span>
                                        </td>
                                        <td>
                                            <span class="table-span">{!! $customer->state !!}</span>
                                        </td>
                                        <td>
                                            <span class="table-span">{!! $customer->zip !!}</span>
                                        </td>
                                        <td>
                                            <span class="table-span">{!! $customer->phone !!}</span>
                                        </td>
                                        <td>
                                            <span class="table-span">{!! $customer->email !!}</span>
                                        </td>
                                        <td>
                                            <a href="#">
                                                <i class="fa fa-close"></i>
                                            </a>
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                            </tbody>
                        </table>

Here are my scripts at the bottom of the page:

<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.18/fh-3.1.4/sc-2.0.0/datatables.min.js"></script>
    <script>
        $(document).ready(function () {


            $(document).ready(function () {
                $('#customers').DataTable();

            });

            var table = $('#customers').DataTable({ //Hier wird die Tabelle zu einem DataTable gemacht (genaue Erklärungen auf DataTables.net).
                fixedHeader : {
                    header : true,
                    footer : false,
                    headerOffset: 0
                },
            });

        });
    </script>

Here is the cdn link from the head:

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.18/fh-3.1.4/sc-2.0.0/datatables.min.css"/>

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.