editor preOpen event
editor preOpen event
Khalid Teli
Posts: 251Questions: 71Answers: 0
Hi,
I am using an preOpen editor event to disable the editing for rows, if status == Confirmed it returns false as shown in code below and it works fine.
agreementEditor.on( 'preOpen', function ( e ) {
var mode = agreementEditor.mode(); // Gets editor mode, (create, edit, remove)
console.log(mode);
var modifier = agreementEditor.modifier(); // Gets the selected row of the table
if ( modifier ) {
var data = agreementTable.row( modifier ).data();
var status = data.status;
if (status == "CONFIRMED"){
alert("You cannot Edit confirmed agreement");
return false;
}
}
} );
I am using a Duplicate button like this:
extend: "selected",
text: 'Duplicate',
action: function ( e, dt, node, config ) {
agreementEditor
.edit( agreementTable.rows( {selected: true} ).indexes(), {
title: 'Duplicate record',
buttons: 'Create from existing'
} )
.mode( 'create' ); }
How can I make the pre open event to ignore the data.status result . So when I click the Duplicate button it should create rows irrespective of the status of the row.
something like if mode === 'duplicate', ignore this preOpen function??
Thank you
This discussion has been closed.
Answers
Inside the
action
function for your duplicate button set a variable such asignore
. Then in your event handler check if that was set or not. If set, then reset it and exit.Allan
@allan
Thank you, works perfect.