Installing angular-datatables with Angular cli but using bootstrap 5 #1563
-
I have a project with bootstrap 5 and I've installed angular-datatables with Angular cli: ng add angular-datatables The installation was successful but when prompted to choose the styling library, the last version of bootstrap provided was 4: ℹ Using package manager: npm
✔ Found compatible package version: [email protected].
✔ Package information loaded.
✔ Package successfully installed.
? Which styling library would you like to use for DataTables? Bootstrap 4
Your project needs Bootstrap CSS installed and configured for changes to take affect.
✅️ Added "jquery" into "dependencies"
✅️ Added "datatables.net" into "dependencies"
✅️ Added "@types/jquery" into "devDependencies"
✅️ Added "@types/datatables.net" into "devDependencies"
✅️ Added "datatables.net-bs4" into "dependencies"
🔍 Installing packages...
✅️ Added "jQuery Core" into angular.json
✅️ Added "DataTables.net Core JS" into angular.json
✅️ Added "DataTables.net Bootstrap 4 CSS" into angular.json
✅️ Added "DataTables.net Bootstrap 4 JS" into angular.json
UPDATE package.json (1712 bytes)
UPDATE angular.json (3998 bytes)
✔ Packages installed successfully.
In the DataTables official site there seems to be a proper integration for bootstrap 5 available. In the face of this info, what should I do? Just use the lib the way it was installed and trust the integrations will actually work? ...or assume Angular cli installations are outdated and install things manually? In case that I should make a manual installation, what are the steps I should follow? Note: I wasn't able to find the proper info about bootstrap integration on docs. Is it there some info about it? Thanks in advance, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi, Bootstrap 5 isn't officially supported yet. You'll need to install it manually. Don't forget to uninstall Bootstrap 4. Although DataTables plugin supports it, I'm waiting for Meanwhile, a PR is always welcome :) |
Beta Was this translation helpful? Give feedback.
-
For the people trying to achieve this manual installation, here it goes how I've done it: Just follow the getting started docs in the manual installation section but instead of this: npm install datatables.net-dt --save ...Do this: npm install datatables.net-bs5 --save An in the angular.json file, instead of this: "projects": {
"your-app-name": {
"architect": {
"build": {
"options": {
"styles": [
"node_modules/datatables.net-dt/css/jquery.dataTables.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/datatables.net/js/jquery.dataTables.js"
],
...
}
} ... do this: "projects": {
"your-app-name": {
"architect": {
"build": {
"options": {
"styles": [
"node_modules/datatables.net-bs5/css/dataTables.bootstrap5.min.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/datatables.net/js/jquery.dataTables.js",
"node_modules/datatables.net-bs5/js/dataTables.bootstrap5.min.js"
],
...
}
} In my case I had to uninstall datatables.net-bs4 before installing the bs5 version as I had already installed it by using the Angular Cli method: npm uninstall datatables.net-bs4 --save |
Beta Was this translation helpful? Give feedback.
For the people trying to achieve this manual installation, here it goes how I've done it:
Just follow the getting started docs in the manual installation section but instead of this:
...Do this:
An in the angular.json file, instead of this: