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

Recommendations on app structure using new SPA features

4 Answers 165 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Mike Powell
Top achievements
Rank 1
Mike Powell asked on 16 May 2013, 07:49 PM
I have been seriously looking over the new kendo features (View, Layout, Router, etc). I am trying to figure out the best practices for structuring my app with said new features and was looking for some input on the subject.

I would appreciate some feedback to the following questions:
  1. My general impression is that the ObservableObject is solely intended for supplying data and event handlers to views+widgets. The responsibility of populating widgets and binding events falling to the bound views and any widgets they contain. Is this assumption correct?
  2. Assuming yes, if I want to pop up a temporary window, or add a widget to one of my bound views, who should be responsible for this? The ObservableObject, View, Widgets, or the Router?
  3. When it comes to displaying and editing data, the impression that I have gotten is that we are supposed to use views (with a form) for single objects, and widgets for collections of objects. Is that correct?
  4. When it comes to binding templates to MVVM bound widgets inside Views, all your examples say to use IDs to script tags within the page. Well what should I do when I am loading templates as strings in RequireJS rather than putting them in the DOM?

Thanks for any help you can provide. I am really eager to start using these new features. :)

4 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 20 May 2013, 01:09 PM
Hello Mike,

Up to your questions:
  1. Yes, the ObservableObject (the ViewModel) is responsible for providing data and event handling to widgets/Views.

  2. Initialization of the widgets/components is done during the binding/rendering process.

  3. The answer of this question depends on your specific scenario. Generally speaking, if you have to deal with a single object, it would be much easier to bind it to a form, but if you have to work with large amount of data, you may consider using Grid or ListView.

  4. You are not limited to use IDs. It is required for the script element to be loaded and to be selectable (via class, name, custom attribute, id etc.)

I hope this information will help. For more details I recommend you to check the SPA blog posts and the corresponding documentation:

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Mike Powell
Top achievements
Rank 1
answered on 20 May 2013, 05:45 PM
I think I might need to clarify my questions.

For #2, I was referring to adding widgets and popping up temporary windows dynamically after the page has been populated by all the views and widgets. For example, when I click a button to pop up a temporary edit window to expose more functionality. Where should I handle these operations? I get the impression that the ObservableObject is not the correct place, since it needs to be ignorant of the views/widgets. So should I package that functionality into a custom widget?

For #4, let me construct a scenario to illustrate my point. We're assuming that all my pertinent code is shared via RequireJS (templates and views loaded via text plugin). Say I have a grid column template I want to share between different views. What would be the best way to have my views reference that template if I am using the declarative style?

5.) I have another question. To me, it's pretty clear that datasources are not meant to handle single objects. So do you recommend we use AJAX calls to populate ObservableObject fields that are monitored by the views? Or just use a datasource that has a collection with only one item?

Hope that helps. Thanks.
0
Alexander Valchev
Telerik team
answered on 22 May 2013, 01:58 PM
Hi Mike,

The ObservableObject is connected with the View and widgets. That said it is OK to reference the View or a particular widget from within the observable. There is no need to package the functionality into a custom widget.

For further guidance please refer to the sample SPA applications available at Kendo UI demo page.

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
Mike Powell
Top achievements
Rank 1
answered on 23 May 2013, 07:46 PM
Thanks for the directions. I was able to find the missing pieces of info I needed from the following "How Do I?" section:
http://docs.kendoui.com/howto/load-templates-external-files
Tags
SPA
Asked by
Mike Powell
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Mike Powell
Top achievements
Rank 1
Share this question
or