-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Form: update Change Properties at Runtime (#6766)
- Loading branch information
1 parent
73c497f
commit 73b41ba
Showing
1 changed file
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() { | ||
|
@@ -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. | ||
|