Skip to content

Commit

Permalink
Form: update Change Properties at Runtime (#6766)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladaskorohodova committed Oct 30, 2024
1 parent 73c497f commit 73b41ba
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
##### jQuery

To change the properties of an editor, get its instance first using the [getEditor(dataField)](/api-reference/10%20UI%20Components/dxForm/3%20Methods/getEditor(dataField).md '/Documentation/ApiReference/UI_Components/dxForm/Methods/#getEditordataField') method. After that, call the **option(optionName, optionValue)** or **option(optionName, options)** method of this instance. This approach is more typical of jQuery.
To change the properties of an editor, get its instance using the [getEditor(dataField)](/api-reference/10%20UI%20Components/dxForm/3%20Methods/getEditor(dataField).md '/Documentation/ApiReference/UI_Components/dxForm/Methods/#getEditordataField') method. Then, call the **option(optionName, optionValue)** or **option(optionName, options)** method of this instance.

<!--JavaScript-->
$(function() {
Expand All @@ -27,6 +27,31 @@ To change the properties of an editor, get its instance first using the [getEdit

[note]The **getEditor(dataField)** method is available for visible form items only.

If you need to preserve changes during Form re-rendering, change editor properties at the item level:

<!--JavaScript-->
$(function() {
const form = $("#formContainer").dxForm({
formData: {
firstName: "John",
lastName: "Heart",
phone: "+1(213) 555-9392",
email: "[email protected]"
}
}).dxForm("instance");

$("#checkBoxContainer").dxCheckBox({
text: 'Disable the First Name Editor',
value: false,
onValueChanged: function (e) {
const options = {};
options.disabled = e.value;
const prevOptions = form.itemOption("firstName").editorOptions;
form.itemOption("firstName", "editorOptions", {...prevOptions, ...options });
}
});
});

##### Angular

To change the properties of an editor, bind the property that should be changed in the [editorOptions](/api-reference/10%20UI%20Components/dxForm/5%20Item%20Types/SimpleItem/editorOptions.md '/Documentation/ApiReference/UI_Components/dxForm/Item_Types/SimpleItem/#editorOptions') object to a component property.
Expand Down

0 comments on commit 73b41ba

Please sign in to comment.