This is a migrated thread and some comments may be shown as answers.

Automatically copy values from view model to other fields

1 Answer 205 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Ansley
Top achievements
Rank 1
Ansley asked on 21 May 2013, 12:16 AM
I have a viewmodel that binds a strongly typed model to the view's controls:

Example: <input type="text" placeholder="Address 1" id="CurrentAddress1" data-bind="value: account.CurrentAddress.Address1"> and <input type="text" placeholder="Address 1" id="PermanentAddress1" data-bind="value: account.PermanentAddress.Address1">

I need functionality, that if a checkbox for "Same As" is checked, the Permanent values in other controls get copied over from the Current values as the user enteres them.

Seems that I need to override either the dataSource or the model bindings, but as a new Kendo developer I am wondering how this would be possible. THanks!

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 22 May 2013, 01:54 PM
Hello,

Kendo does not support such copying functionality which you can use. You will need to manually iterate through the properties of the model and copy the values.
Another approach would be to set the whole nested object with a new one, however this would have slightly different effect.

http://jsbin.com/ebivoc/3/edit

Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
Ansley
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or