in editor I have some fields on initialisation. They will be populated onCreate. After creation (that is on editing the row) those fields should be hidden or readonly. How do I change this?
Here is an example from my coding with a different Editor event. I set, show and hide fields dynamically:
myEditor
.dependent('fixed.fee', function (val, data, callback) {
var self = myEditor;
if (val != 0 && val > '-') { //if the fee contains a not 0 value
self.show(['fixed.fee_date']);
if (self.val('fixed.fee_date') <= '') {
self.field('fixed.fee_date').set(inTwoDays);
}
} else {
self.set({'fixed.fee_date': ''})
.hide(['fixed.fee_date']);
}
})
It was even more simple as I thought. I need to give password a vulue for a new record, but hide the field when editing, so the password can not be changed:
~~~js
membersEditor
.on( 'open', function (e, d, action) {
var pwd = $.generateRandomPassword(8);
if(action=='create'){
membersEditor.field('members.password').val( pwd );
}
else{
membersEditor.hide(['members.password']);
}
});
~~ ~
Thanks for your help
Answers
Would be great if you had some code!
But you can do this using an event e.g. this one: https://editor.datatables.net/reference/event/postCreate
Here is an example from my coding with a different Editor event. I set, show and hide fields dynamically:
Take a look at the api Field instance methods to see how to show, hide, set, get field values.
https://editor.datatables.net/reference/api/
It was even more simple as I thought. I need to give password a vulue for a new record, but hide the field when editing, so the password can not be changed:
~~~js
membersEditor
.on( 'open', function (e, d, action) {
var pwd = $.generateRandomPassword(8);
if(action=='create'){
membersEditor.field('members.password').val( pwd );
}
else{
membersEditor.hide(['members.password']);
}
});
~~ ~
Thanks for your help