How to know the button selected by the user
How to know the button selected by the user
Clarence
Posts: 19Questions: 7Answers: 0
This I create table
table = $('#user').DataTable( {
dom: "Bfrtip",
ajax: "/api/",
columns: [
{ data: "customers.name"},
],
order: [[ 7, "desc" ]],
select: true,
pageLength: 1000,
buttons: [
{
extend: "edit",
editor: editor,
text: 'editor',
formTitle: "editor",
formButtons: [
{
label: 'editor',
fn: function () {
this.submit( null, null, function (data) {
$.each( data.data, function ( key, values ) {
data.data[key]['customers']['status'] = "editor";
} );
} )
}
},
],
},
{ extend: "edit",
editor: editor,
text: 'delete',
formTitle: "delete",
formButtons: [
{
label: 'delete',
fn: function () {
this.submit( null, null, function (data) {
$.each( data.data, function ( key, values ) {
data.data[key]['customers']['status'] = "delete";
} );
} )
}
},
],
},
],
} );
I want user chooses to "delete" button the field to "disable"
But this not work.
editor.on('open', function (e, type) {
var mode = editor.mode();
var ids = editor.ids(true);
var data = table.rows(ids).data();
if (data[0]['customers']['status'] === 'delete') {
editor.field( 'customers.name' ).disable();
editor.field( 'customers.nickname' ).disable();
editor.field( 'customers.image' ).disable();
}
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The
open
event is called as a result ofedit()
being triggered. So it doesn't have any knowledge of which button was pressed. You'd need to usebutton-action
instead to trigger an action when a specific button is pressed (e.g. disabling or enabling a field).Allan