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

Updating an array element

7 Answers 482 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 01 Dec 2014, 04:42 PM
Whats the best way to update an array element?

My array list is massive (large objects) so if I clone it, change THAT array, then set the clone back, there's some noticable lag in the app.

How would I just update a array element, or like a single property OF that array element.

7 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 03 Dec 2014, 09:32 AM
Hi Steve,

Please check this example as it demonstrates how to update single property of an array element: http://dojo.telerik.com/@valchev/OtIjI

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 03 Dec 2014, 05:50 PM
Okay let me ask you this...

Given this in my template
                <span data-bind="attr: { class: getStatusClass }"><span data-bind="text: Status"></span></span>
                <span class="logcount" title="Encounters Logged"><span data-bind="text: LogCount"></span>

When I update "Status" on the item as you defined, the text updates okay, but the getStatusClass function isn't called.  I used to have it as <span class="status #: Status #" but that wasn't updating through the model change...so I moved it to a function.

What should I be doing here?
0
Alexander Valchev
Telerik team
answered on 05 Dec 2014, 11:55 AM
Hello Steve,

Could you please update the Dojo example that I provided below so it illustrates your exact case?
In this way I will be able to examine your exact implementation and assist you further.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 05 Dec 2014, 02:46 PM
Sure here: http://jsbin.com/famixo/2/

Why aren't the completed items turning green?
0
Alexander Valchev
Telerik team
answered on 05 Dec 2014, 03:21 PM
Hi Steve,

Issue occurs because dependent methods must use the get method to get field values. For more information please check this help article:
Here is a link to the updated example: http://jsbin.com/qiqexuroxa/1/edit

Please also note that the template should have a single root item.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 05 Dec 2014, 03:34 PM
Ah geez yeah, thanks

Hey, is there a way to do it right from the template so I don't have to have a function to return a single bound value?
0
Alexander Valchev
Telerik team
answered on 09 Dec 2014, 09:28 AM
Hi Steve,

The getStatusClass method basically gets the "Status" value. You may bind the class directly to the "Status" field.

Regards,
Alexander Valchev
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
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Alexander Valchev
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or