How does Datatable editor and Tabletools work together
How does Datatable editor and Tabletools work together
In the example in:
https://editor.datatables.net/examples/inline-editing/simple.html
I am trying to get the TableTools buttons "New", "Edit", and "Delete" to appear, but I can't.
I initialize a table using
var data_table = $('#table').Datatable({
data: data,
columns :[ /* some columns */],
tableTools: {
sRowSelect: "os",
sRowSelector: 'td:first-child',
aButtons: [
{ sExtends: "editor_create", editor: editor },
{ sExtends: "editor_edit", editor: editor },
{ sExtends: "editor_remove", editor: editor }
]
}
});
However, it might be worth mentioning that I use the Bootstrap datatable css and js files for bootstrap integration: dataTables.bootstrap.js
and dataTables.bootstrap.css
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
First, are you including the TableTools js file?
Second, your initialisation might need a path to swf.
Looks like you might be missing this part:
The
T
indom
tells DataTables to use the TableTools extension.Allan
Thanks both suggestions helped. The buttons do appear now, but when I press 'New' no popup appears, but the entire page gets pushed dynamically further down, seemingly to make room for the pop-up form which never appears. Hope it made sense?
Sounds like you need to include the Editor CSS is my guess.
Can you link to the page so we can confirm what is happening?
Allan
Thanks for the link in the PM. It does indeed look like there are a couple of files missing. Specifically:
The Editor Bootstrap examples shows all of the include files needed: http://editor.datatables.net/examples/styling/bootstrap.html
Allan
Indeed some of the .js and .css were missing. I have now included them but with no avail. The problem still occurs. I am stumped, nothing comes up in my chrome javascript console for me to debug this problem. Any pointers?
edit - Sorry, crossed threads! Will reply back to this one shortly!
The console in Chrome shows:
Include the Editor script before the plug-in for it and hopefully that should do it.
Allan
This is the order my js incudes now. I still get the 'undefined' error in console.
html
<script src="../bootstrap/bootstrap-3.1.1/dist/js/bootstrap.min.js"></script>
<script src="../bootstrap/bootstrap-3.1.1/docs/assets/js/docs.min.js"></script>
<script src="../datatable/DataTables-1.10.0/media/js/jquery.js"></script>
<script src="../datatable/DataTables-1.10.0/media/js/jquery.dataTables.js"></script>
<script src="../datatable/DataTables-1.10.0/extensions/Scroller/js/dataTables.scroller.js"></script>
<script src="../datatable/DataTables-1.10.0/bootstrap/dataTables.bootstrap.js"></script>
<script src="../datatable/DataTables-1.10.0/extensions/TableTools/js/dataTables.tableTools.min.js"></script>
<script src="../datatable/DataTables-1.10.0/extensions/Editor-1.3.2/js/dataTables.editor.min.js"></script>
<script src="../datatable/DataTables-1.10.0/bootstrap/dataTables.bootstrap.js"></script>
<script src="../datatable/DataTables-1.10.0/extensions/Editor-1.3.2/examples/resources/bootstrap/editor.bootstrap.js"></script>
Yup need to update to TableTools 2.2.2 :-). As the release notes for Editor 1.3.2 note, TableTools 2.2.2 or later is required if you are using TableTools. Sorry about that - it was a bug across the two libraries.
Allan