how to make all controls readonly according to a field value
thanks, but this will make the control readonly all the time.
I use this code this.form.FromDtm.set_readOnly(true); in afterLoadEntity(), but I'm asking, if we can set the form to readonly according to a certain field value without use this code for every control in the form.
@amrgDev You can use a lookup and use se setectchange event
checkout the ReadOnly dialog example in the Serenity demo. simple variation to line 41 & 44 should get you the result.
https://github.com/volkanceylan/Serene/blob/master/Serene/Serene.Web/Modules/BasicSamples/Dialogs/ReadOnlyDialog/ReadOnlyDialog.ts
export class PayDialog extends Serenity.EntityDialog<PayRow, any> {
.........................
protected updateInterface() {
super.updateInterface();
if (!this.isNew()) {
if (this.entity.Fact) {
Serenity.EditorUtils.setReadonly(this.element.find('.editor'), true);
this.element.find('sup').hide();
this.deleteButton.hide();
Serenity.EditorUtils.setReadonly(this.form.FactCost.element, false);
Serenity.EditorUtils.setReadonly(this.form.DateCost.element, false);
Serenity.EditorUtils.setReadonly(this.form.Notes.element, false);
}
}
}
Thanks @Zahar661 ,this match my requirments
Most helpful comment