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

observable does not obtain property defined on array

1 Answer 51 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 05 May 2015, 10:26 PM

Create an array.  Add a non numeric property to it with a value.  Assign that array to an object as a property.  Create an observable of that object.  The array no longer has its non numeric property.  How can this be avoided?  The same test with an object (which is all an array is) works fine.  

http://jsfiddle.net/n54tke37/3/

 

The first half of that fiddle shows the object case which works.  The second half shows the array case which does not.  

 

 

 

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 07 May 2015, 02:31 PM

Hello Robert,

I'm afraid that this is by design behavior of the ObservableArray. As you know when converted into an observable object, the values of the Array will be used for constructing the ObservableArray instance. This means that custom fields defined on the original Array instance will not be transferred to the ObservableArray. If you need this field attached to the ObservableArray you will need to attach it manually, however there will be no change tracking available.

Regards,
Rosen
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
Robert
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or