Where do I find detailed information about custom buttons
Where do I find detailed information about custom buttons
anoshiri
Posts: 5Questions: 1Answers: 0
Can you point me to how I can implement custom buttons in my table? I need a button to change status of selected items. The documentation is not very clear to me. Meanwhile, I'm running Laravel at the backend.
Thanks in advance.
By the way, great software. I'm enjoying it. It saves me alot of development time.
This discussion has been closed.
Answers
Details on how to implement custom buttons are available here. If you have any specific questions about it, please let us know.
Allan
Thanks Allan.
I'm getting an error "Uncaught TypeError: Cannot read property 'rows' of undefined" on this line:
dt.rows( {selected: true}).data().toArray();
See code below:
'buttons' => [
['extend' => 'remove','editor' => 'editor', 'text' => '<i class="fa fa-check fa-x5"></i> Activate',
'formTitle' => 'Activate Batches',
'formMessage' => 'Are you sure you want to activate these batches?',
'formButtons' => [
[ 'text'=> 'Activate', 'action' => 'function ( e, dt, node, config ) {
var ajaxData = dt.rows( {selected: true}).data().toArray();
console.log("it works");
}'
],
[ 'text'=> 'Cancel', 'action'=> 'function () { this.close(); }' ]
]],
['action'=> 'deactivate', 'text' => '<i class="fa fa-print fa-x5"></i> Deactivate'],
]
Can you give me a link to a page that shows the issue please? That looks like it should work.
Allan
I do not have the project online yet. Maybe these screenshots could help.
Where have you defined
dt
?Maybe you can post a test case showing the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I got a little confused by the code shown above as well, but the
dt
appears to be passed in as an argument to theaction
function:That function signature is correct, so that isn't the issue.
That said, there is somewhere that is calling
dt
where it isn't defined, and I don't know what that is from the information above. Can you show us your full initialisation code and ideally link to a test case please?Allan
Creating a test case on live.datatables.net is not giving me joy at all. I'm getting JQuery is not defined. Here is the link http://live.datatables.net/weqasate/2/edit
You believe you can find full code initialisation there.
Thanks for your help
I've moved the order of the Javascript around a little: http://live.datatables.net/weqasate/3/edit (load jQuery first, then DataTables and then its extensions).
Its giving an error about
cannot read property style of undefined
as thecolumns
array does not contain the same number of columns as the HTML table (6).Allan
I have modified content: http://live.datatables.net/weqasate/5/edit
Can you review with this?
The Deactivate button is giving an error because it has no
action
:i.e. when you click it, there is nothing for it to do. That isn't expected in Buttons so it throws an error.
Allan