Could anyone help me with bootstrap 4 styling datatables editor?
Could anyone help me with bootstrap 4 styling datatables editor?
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
I'm following the example in this page:
https://editor.datatables.net/examples/styling/bootstrap4
What I don't understand is how the modal is opened pressing the butons new/edit/delete. I could open a modal defined by me in the html, but I would like to have the same behaviour as the page, when validating fields for example.
Then on the modal I had to capture this events..
$("#saveChanges").on ("click", () =>
{
});
$("#updateChanges").on ("click", () =>
{
}
But as don't see this things on the example I imagine that there is something bad I'm doing.
I'm working with typescript/html on the frontend and C++ on the backend.
Thank you in advance!
Answers
If you have the Bootstrap 4 integration files for Editor loaded, and Bootstrap 4's Javascript, then Editor will use the Bootstrap 4 model whenever it needs to show the full form. It does that by having a plug-in system for the "display controller", and the Bootstrap 4 integration sets the Bootstrap 4 model for that.
If that isn't working for you, quite possibly you don't have all the right files being loaded. The download builder is the best way to make sure you have everything needed for DataTables and Editor.
If that doesn't resolve the issue, then we'd need a link to a page showing the issue please.
Much respect! Is there a package you are using for handling the HTTP parameters?
Allan
Hi Alan, thank you for your answer.
I followed the download builder page and installed the packages as this:
npm install datatables.net-bs4
npm install datatables.net-editor
node node_modules/datatables.net-editor/install.js libs/Editor-2.2.2-Licensed.zip
npm install datatables.net-buttons-bs4
npm install datatables.net-responsive-bs4
npm install datatables.net-select-bs4
Then, imported the following files on my .ts file:
import "../node_modules/datatables.net/js/jquery.dataTables.js"
import "../node_modules/datatables.net-bs4/js/dataTables.bootstrap4.min";
import "../node_modules/datatables.net-buttons/js/dataTables.buttons.min.js"
import "../node_modules/bootstrap/dist/js/bootstrap.min";
import "../node_modules/datatables.net-buttons-bs4"
import "../node_modules/datatables.net-select-bs4"
import "../node_modules/datatables.net-responsive-bs4"
import Editor from "datatables.net-editor";
import DataTable, { AjaxData, Api, Config } from "datatables.net-bs4";
And on the html I added the following lines:
<link rel=stylesheet href=node_modules/bootstrap/dist/css/bootstrap.min.css type=text/css>
<link rel=stylesheet href=./node_modules/datatables.net-bs4/css/dataTables.bootstrap4.css type=text/css>
<link rel=stylesheet href=./node_modules/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css type=text/css>
<link rel=stylesheet href=./node_modules/datatables.net-select-bs4/css/select.bootstrap4.min.css type=text/css>
<link rel=stylesheet href=./node_modules/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css type=text/css>
I don't know if there is something I'm doing wrong.
Regarding the C++ package, we made our own libraries for handling REST apis
Eduardo
Do
npm install datatables.net-editor-bs4
and then rerun the Editor install script.Then change:
To be:
And that should do it.
It looks like at the moment the Bootstrap 4 Editor integration isn't being loaded in.
Allan
Thank you Allan, I did the changes that you suggested, but I have a problem defining the buttons:
The 'editor' property is not accepted.
On the same way, I can't execute the following code:
// Display the buttons
new DataTable.Buttons(table, [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
]);
This is defined on the example in
https://editor.datatables.net/examples/styling/bootstrap4
I will appreciate any help
Thank you!!
Looks like you might need to add
as any
after the object ({extend: ...} as any
) unfortunately. I think that was working, but something appears to have gone wrong there. I'll dig into it.Allan
Hi Alan now it's working, I added 'as any' for each button.
If you don't mind, could please help me to include some export buttons?
I would like to include a pdf button and followed this example:
https://editor.datatables.net/examples/extensions/exportButtons.html
So I installed pdfmake:
npm install --save pdfmake
Then, added the following line on my source:
import pdfmake from 'pdfmake';
Added this piece of code:
But the button does not appear, this is a what I see:
There is no button when I press 'Export'
This is the package.json:
Thank you in advance !!
Have you also got this?:
When using ESModules pdfmake doesn't get registered globally, so you need to "tell" Buttons about it.
Allan
Hi Allan, I cannot make the call, I'm having this error:
I imported the following pdfmake as this:
import * as pdfMake from "pdfmake/build/pdfmake";
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
Any idea? Thank you for your help !!
That's just a Typescript error. Try:
Allan