Bootstrap 4 Not Initializing
Bootstrap 4 Not Initializing
zgoforth
Posts: 493Questions: 98Answers: 2
Hello, so I am trying to implement the Bootstrap 4 styling for my DataTable, but when I put the .js and .css files into the top of my code to initialize it, nothing happens. I copied the exact order of .js and .css files that is in my code and put into this test case. https://jsfiddle.net/2oyz4q3e/
This discussion has been closed.
Replies
There are a few problems. First you need to load Bootstrap itself. Take a look at the Bootstrap 4 example. open the
CSS
tab and you will see this:https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css
I added this to your example.
You are loading conflicting CSS by using
jquery.dataTables.min.css
. I commented this out of your example.You also should use Bootstrap classes on the
table
tag. You can see these by clicking theHTML
tab of the example.Here is the updated example:
https://jsfiddle.net/qt94h281/
The easiest way to get the proper files is to use the Download Builder. The BS4 Styling doc contains more information.
Kevin
@kthorngren Ok. Thank you, I fixed that. Now my Table looks like this,
I want to move the buttons "Excel, PDF, and Print to the right side, so I tried this
and the buttons do not move.
The Buttons doc explains how to display the buttons. You are using the
dom
option for this. So you basically need to place theB
in the string where you want it. Thedom
docs show an example of using Bootstrap 4 classes to place the elements where you want.Kevin
@kthorngren so I altered around the "B" to
dom: 'frtBip',
aswell as tried different placements, and it won't move to the right, either goes above my search bar, below my search bar, or below the footer of the table.Did you look at the Bootstrap 4 classes for the
dom
option?If you are having problem please update your test case and provide the new link.
Kevin
@kthorngren Yes. I looked at the Buttons feature as well as the dom option, and followed as instructed on each page. I will add a test case to show you. I changed the dom:'Bfrtip', to dom:'frBtip', and I still cannot get the buttons on the right side. It only goes on the left side whether it be the top or bottom.
You still aren't using the Bootstrap 4 styling for the
dom
option. Look at thedom
docs here. You need to use the Bootstrap Grid System to layout the elements.Kevin
@kthorngren here is my test case. For some reason my static Data variable is not loading into the table https://jsfiddle.net/uv5eh3nz/
@kthorngren I looked at it, I do not understand what this is and where to implement it?
"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
The script has this error:
You have
dom:'frBtip',
. Replace thefrBtip
string with the example Bootstrap string. For example:https://jsfiddle.net/qt94h281/1/
Kevin
@kthorngren Thanks for the clarification. One last question. Is it possible to change the color of the buttons?
See this thread.
Kevin
@kthorngren in the test case linked here. I want the buttons to be the "dark" class, http://live.datatables.net/yonakowu/602/edit but it doesn't change?
I've seen this before . The Bootstrap.css file doesn't seem to have the
btn-dark
CSS so you will need to add your own. See the updated example:http://live.datatables.net/cedeqotu/1/edit
I added another button using
btn-success
to show that the other buttons built into bootstrap.css work. The lack ofbtn-dark
in the bootstrap.css is a Bootstrap issue not a Datatables issue.Kevin
@kthorngren Appreciate it. I checked out the bootstrap website and there isn't really a forum or anywhere to display questions/concerns.
The bottom of this page links to their Github issues page:
https://getbootstrap.com/docs/4.5/about/overview/
Or As Colin mentioned in another of your threads look at Stack Overflow.
Don't get me wrong. You asked a valid question. Just pointing out that the issue is not Datatabes related.
Kevin