-
Notifications
You must be signed in to change notification settings - Fork 804
UI EnableDisableControls
Victor Tomaili edited this page May 3, 2021
·
1 revision
Code sample: in Serene/BasicSamples/Dialogs/ReadOnlyDialog
Saltarelle version:
EditorUtils.SetReadOnly(form.MyField, true)
TypeScript version:
constructor() {
super();
// Add change event to control field
this.form.EnableField.change(e =>
{
if (this.form.EnableField.value == 1)
// Set read only to true for a field
Serenity.EditorUtils.setReadOnly(this.form.TestField, true);
if (this.form.EnableField.value == 2)
// Set read only to false for a field
Serenity.EditorUtils.setReadOnly(this.form.TestField, false);
}
);
TypeScript version:
constructor() {
super();
// Add change event to lookup field
this.form.LookUpField.ChangeSelect2(e =>
{
// Set read only to true for a field
Serenity.EditorUtils.setReadOnly(this.form.TestField, true);
}
);
For make a field readonly use the ReadOnlyAttribute.
[FormScript("Test.Test_Table")]
[BasedOnRow(typeof(Entities.Test_TableRow))]
public class Test_TableRow
{
[ReadOnly(true)]
public String MyField { get; set; }
If you want to ensure that a field is read-only only in update mode (and editable in insert mode), use the attribute UpdatableAttribute. In this way when the Form is open in insert mode (new) field is editable. When the Form is open in edit mode, the field is read-only.
[FormScript("Test.Test_Table")]
[BasedOnRow(typeof(Entities.Test_TableRow))]
public class Test_TableRow
{
[Updatable(false)]
public String MyField { get; set; }
Copyright © Serenity Platform 2017-present. All rights reserved.
Documentation | Serene Template | Live Demo | Premium Support | Issues | Discussions