Setting value via button
Setting value via button
Hi,
I am trying to build a super simple custom button that should insert a value 1 to a database bool column 'active'
But it is not working...
Here is my code:
var editor = new $.fn.dataTable.Editor( {
...
});
new $.fn.dataTable.Buttons( table, [
{
text: 'Activate',
action: function ( e, dt, node, config ) {
editor.field( 'active').set( 1 );
editor.submit();
//Shall I reload the table after?
//table.ajax.reload( null, false );
},
enabled: false
}
] );
The problem is that there are no errors in browser console so I am not able to debug the problem.
I assume then that something is wrong with submit it self (there is also no JSON data passed while clicking button in Chrome dev-tools Network tab - no request at all)
All fields & db columns names are properly set...
Any idea what I have made wrong?
This question has an accepted answers - jump to answer
Answers
I'm not clear where that code would be called. If it's on a button on the main table, then you would need to go into
edit()
first to start the edit. Can you give more context, please, or link to your page so we can see this in action,Colin
Thank You Colin for a tip, You are right with edit().
I have modified my button to code below and now it is working