datatables / dist-datatables-bootstrap5 Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Hello,
I hope to not open this issue for nothing, but after many tests, it seems that the dark mode doesn't use the recommendation of Bootstrap.
To use the dark mode, there is a pretty simple doc.
[Just] add
data-bs-theme="light"
ordata-bs-theme="dark"
to the parent
the highest element is html
, same workflow as Bootstrap doc page.
Bootstrap shared this JS script to make the implementation easy.
The problem (imo) is the implementation with html.dark
in the file is not correct.
It should be in:
[data-bs-theme="dark"] {
table.dataTable td.dt-control:before {
color: rgba(255, 255, 255, 0.5);
}
table.dataTable tr.dt-hasChild td.dt-control:before {
color: rgba(255, 255, 255, 0.5);
}
}
The demo page DataTables example - Bootstrap 5 styling is working, because you have this snippet hack of JS code:
if (mode === 'dark') {
var html = document.getElementsByTagName('html')[0];
html.className += html.className + ' dark';
html.setAttribute('data-bs-theme', 'dark');
}
Is it possible to implement dark mode properly?
Best,
I experimented a bit with Datatables 2.0 and various Bootstrap 5 Table variants (i.e. table header different color than table body). It seems that class dataTables
which is inserted by datatables.js overrides most Bootstrap 5 classes (i.e. table-dark
does have white text, but not black background).
Example:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.datatables.net/2.0.1/css/dataTables.bootstrap5.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.datatables.net/2.0.1/js/dataTables.min.js"></script>
<script src="https://cdn.datatables.net/2.0.1/js/dataTables.bootstrap5.min.js"></script>
</head>
<body>
<div class="container pt-3">
<h1>Datatables test</h1>
<div class="my-2">
<table id="sample-data" class="table table-striped table-success">
<thead class="table-dark">
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011-04-25</td>
<td>$320,800</td>
</tr>
<tr class="table-info">
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011-07-25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009-01-12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012-03-29</td>
<td>$433,060</td>
</tr>
<tr>
<td>Airi Satou</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>33</td>
<td>2008-11-28</td>
<td>$162,700</td>
</tr>
</tbody>
</table>
</div>
</div>
<script>
$(document).ready(function() {
new DataTable('#sample-data', {});
});
</script>
</body>
</html>
In dataTables.bootstrap5.js the Default class modification adds the .card class to sProcessing. The result is that the processing message div gets height: 100% from bootstrap 5's .card css which makes the processing message box unsightly. I'd recommend either overriding the height in div.dataTables_processing or not using the .card class in the js at all.
Error with Composer:
[InvalidArgumentException]
Could not find a version of package datatables.net/datatables.net matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability.
CSS tokens defined at the top of the file are used in sections such as this one :
Dist-DataTables-Bootstrap5/css/dataTables.bootstrap5.css
Lines 281 to 304 in d282429
Each time, the use of the token follows a definition of the same CSS property with hard-coded values, precisely those the token intends to replace.
These lines seem to have been incorrectly merged or auto-generated.
This issue certainly spans all the auto-synced Github repositories ...
Uncaught TypeError: Cannot read properties of undefined (reading 'defaults')
Also reported in yajra/laravel-datatables-vite#9. Tested and confirmed working on 1.13.6.
It is missing this dependency https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js that is required for datatables to work.
The only js bundled in https://cdnjs.com/libraries/datatables.net-bs5 coming from this repository is https://cdnjs.cloudflare.com/ajax/libs/datatables.net-bs5/1.12.1/dataTables.bootstrap5.js which does not work without the bundled jquery.
The processing indicator is not shown because the final CSS contains an invalid value for the background
property in 1.13.2
background: 13 110 253;
in 1.13.1 it was valid, with
background: rgba(13, 110, 253, 0.9);
Good day,
I'm using this package to style my dataTables using Bootstrap5. This is how the pagination looks like with 1.13.7
version.
And the code uses a ul
tag
However, after installing the update, the pagination looks like this:
And it uses span
tags instead of the ul
list element.
Was that intended? How may I keep the current look and use the latest version of the package?
Thank you
Hi,
I´m getting the following error with last dev version of datatables and bs5 plugin.
jquery.min.js:2 Uncaught TypeError: Cannot read properties of undefined (reading 'nodeType') at S.fn.init.attr (jquery.min.js:2:65491) at $ (jquery.min.js:2:32561) at S.fn.init.attr (jquery.min.js:2:65332) at o.ext.renderer.pageButton.bootstrap (dataTables.bootstrap5.min.js:1:1953) at S.fn.init.fn (jquery.dataTables.min.js:1:34084) at jquery.dataTables.min.js:1:47121 at Function.map (jquery.min.js:2:3536) at R (jquery.dataTables.min.js:1:47068) at v (jquery.dataTables.min.js:1:23286) at B.<anonymous> (jquery.dataTables.min.js:1:54760)
The highlight in the paginator is not updated when switch between pages. Show the gif.
Any clue?
With version 1.13.2 I get this error message:
jquery.dataTables.mjs:59
Uncaught TypeError: Cannot set properties of undefined (setting '$')
at DataTable (jquery.dataTables.mjs:59:7)
at Comp.use (datatables.net-vue.esm.js:26522:3)
at setup (DataTableNetComponent.vue:5:11)
at callWithErrorHandling (runtime-core.esm-bundler.js:173:22)
at setupStatefulComponent (runtime-core.esm-bundler.js:7265:29)
at setupComponent (runtime-core.esm-bundler.js:7220:11)
at mountComponent (runtime-core.esm-bundler.js:5542:13)
at processComponent (runtime-core.esm-bundler.js:5517:17)
at patch (runtime-core.esm-bundler.js:5119:21)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5656:21)
Changing the version back to 1.12.1 fixes the problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.