DTE Duplicate button – change value of a field(s)
DTE Duplicate button – change value of a field(s)
coderx
Posts: 45Questions: 7Answers: 0
Hello,
considering the example Duplicate button, how should I correctly proceed to change value of field(s) before duplication?
E.g.:
Imagine you duplicate a person, the field "Site" should stay the same, but other fields should be empty. // This example does not make much sense, but considering the source Duplicate button.
action: function ( e, dt, node, config ) {
// Start in edit mode, and then change to create
editor
.edit( table.rows( {selected: true} ).indexes(), {
title: 'Duplicate record',
buttons: 'Create from existing'
} )
// So what should be done here?
// Before going to mode( 'create' )
// .setValue("first_name", null);
// .setValue("last_name", null);
// .setValue("phone", null);
.set( 'first_name', "Test name" ) // This works, but it is the correct way?
.mode( 'create' );
}
Have a great day!
Peter
This discussion has been closed.
Replies
There are a couple of options:
edit()
on the selected row, instead callcreate()
and then fill in the field value based on the selected row's data (table.rows({selected:true}).data()
).I'd take the second approach if you are wanting to keep only a single value. Equally, I'd take the first approach if you wanted to remove only a single value!
Allan
That is really great recommendation! Thanks, Allan!