1

I'm trying to make Angular-Datatable (https://l-lin.github.io/angular-datatables/) style like Bootstrap. So, i have the following in my angular.json file:

 "styles": [
              "src/styles.css",
              "node_modules/bootstrap/dist/css/bootstrap.css",
              "node_modules/datatables.net-bs/css/dataTables.bootstrap.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.slim.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js",
              "node_modules/popper.js/dist/umd/popper.js",
              "node_modules/datatables.net/js/jquery.dataTables.js",
              "node_modules/datatables.net-bs/js/dataTables.bootstrap.js"
            ]

But my datatable look like this:

enter image description here

My project can be found in GitHub: https://github.com/rlanhellas/together-admin

4
  • if you share a Stackblitz, it'll be easier to help Commented Apr 27, 2019 at 3:39
  • I edited my post with code in GitHub Commented Apr 28, 2019 at 13:23
  • where is the datatable in your project (stackblitz.com/edit/github-xqzvb8) ? Commented Apr 29, 2019 at 4:58
  • @AkberIqbal, Inside "/src/app/usuario/usuario.component.html" Commented Apr 29, 2019 at 13:49

2 Answers 2

1

I had to add these to the bottom of the index.html to get bootstrap styling to work for datatables:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" 
type="text/javascript"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js" 
type="text/javascript"></script> 
<script src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js" 
type="text/javascript"></script> 
Sign up to request clarification or add additional context in comments.

Comments

0

I think, you need to add all the below CDNs to resolve your styling issues. This has worked for me too...!!

<link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap4.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="https://cdn.datatables.net/1.11.3/js/dataTables.bootstrap4.min.js" type="text/javascript"></script>

I don't know, why we need to add this CDNs even after installing all the datatable packages and modifying angular.json file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.