Avatar of merijn van der leek
merijn van der leek
 asked on

bootstrap datatable

I wanna use a bootstrap data table but i cant get it to work.
this it the code in my header:
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
    <script type="text/javascript"  src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>>

Open in new window


What line do i need to add to get bootstarp datatable since the one i have been using does not seem to work.
Web DevelopmentCSSHTMLJavaScriptBootstrap

Avatar of undefined
Last Comment
merijn van der leek

8/22/2022 - Mon
Daniel Pineault

Norie

Try adding this link in the header.


<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js"></script>

Chris Stanyon

You might want to show us the code you currently have.

Once you've included the datatables script and styles, you need to initialise the datatable, based on the ID of your table. In your scripts above, you've included the jquery datatables plugin. The bootstrap datatables plugin is a seperate package, so if you specifically want that, you'll also need to include it, as pointed out by Norie.

You initialise the table in your DOM ready block:

$(function() {
    $('#myTable').DataTable();
});

Open in new window

The above code assumes your table has an ID of myTable

<table id="myTable">
    ...
</table>
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
lenamtl

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
merijn van der leek

ASKER
Thanks everyone for the help!