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

[Solved] Conflicting information regarding AngularJS and Kendo MVVM

3 Answers 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DaveJ
Top achievements
Rank 1
DaveJ asked on 23 Feb 2015, 11:02 PM
At the top of your AngularJS + Kendo introduction documentation (http://docs.telerik.com/kendo-ui/AngularJS/introduction) you specifically mention: "If you are using AngularJS then you probably want to use Angular's own routing mechanism and data binding. Do not mix that with Kendo MVVM."

However, in your Kendo DataSource vs AngularJS Scope documentation (http://docs.telerik.com/kendo-ui/AngularJS/data-source), you specifically mention the problem of using the grid with a standard Javascript object as it will not reflect changes in the grid. You then say that the "fix" to this is to use an ObservableArray as the grid's data source. However, an ObservableArray is part of your MVVM framework.

In light of this, what is Telerik's suggested approach? I tend to agree that AngularJS models and Kendo MVVM should not be mixed. However, then how can the grid work correctly with plain AngularJS Javascript models?

And the reverse is also problematic - if using Kendo MVVM as the View Model, then creating other widgets (eg DateTimePicker, ComboBox, etc) using the Angular-Kendo bindings will fail to appropriately trigger events on the MVVM constructs like ObservableObject, ObservableArray, etc. 

Can you please provide guidance on whether or not Kendo MVVM should be used with Angular-Kendo or not? If yes, please provide examples of how to bind Angular-Kendo widgets to MVVM models complete with event triggering. If no, please provide examples of how to work correctly with the grid when using plain Javascript objects as the DataSource.

3 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 25 Feb 2015, 09:28 AM

Hello Yaron,

You are right that Kendo UI MVVM and AngularJS are similar but mutually exclusive, therefore they should not be used together. As for using the observable array - the Kendo UI DataSource will still use observable array even with the AngularJS bindings, and this is perfectly fine, and should not worry you, as even if you pass a plain array it will be converted to an observable one in the background as the widgets still rely on this functionality. As for a demo, here is a link:

http://dojo.telerik.com/EhIta

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
DaveJ
Top achievements
Rank 1
answered on 17 Mar 2015, 07:47 PM
Hi Kiril,

Unfortunately, the solution you provided is not good because even though the grid is being provided with a plain Javascript model object, it is duplicating it by creating an observable array out of it. In other words, the real model that you have and that is tied into Angular bindings is no longer connected with the model the grid has, as the grid is using a new observable array object. This makes it so that any changes that happen in the grid will not be reflected to the original Javascript object that is used throughout the rest of the Angular application.

Please let me know your thoughts.
0
Kiril Nikolov
Telerik team
answered on 19 Mar 2015, 08:11 AM

Hello Yaron,

The Grid does not have a ng-model directive for example, so the data is automatically updated in a two-way binding to the model. However there are remote data operations, that can also work with local data via custom transport definitions, so you can update the data back to the original array. Here is an example that you can adapt for AngularJS usage:

http://docs.telerik.com/kendo-ui/web/grid/how-to/grid-localstorage-crud

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