Sencha ExtJs5 Multiple models in one model and and one View - extjs

I'm new to ExtJs , so not sure how to implement the below scenario.
I do have one form which have multiple sections and table. Each section fields are binding with one model variables.
Now i need to fetch the data from the java models and assign the data to fields. In Java the model structure is : Model A -> Model B, Model C, Model D.
Here, Model A is the main Model and Model B, Model C, Model D are the sub models to the main model.
The same structure need to apply in ExtJs View/Controller. Main form binding with Model A and all form sections are binding with Model B / C / D .
How can I work on this scenario?

Best practice is to have models via the Ext.data.model which then are hosted by the Ext.data.store. You can setup the hierarchy as you need and then you just need to populate the store with the data.
Stores have various proxies to get populated from different sources.
After that you provide stores to different components as data which bind to them and provide the UI.

one cannot "fetch data from the Java models" ...use an ExtJS Store instead.

Related

Backbone.js - nested models & more then one model in collection?

Can one have nested models in backbone.js?
Example: Model A has one of its attributes as Model B
Can one store more then one model type in collection?
Yes you can store models in attributes (nesting models). The main thing to watch out for is that change events to the nested model or collection will not propagate to the outside model.
You could use different models in a collection, but the default create and add methods will only create one type of model if they are passed attributes rather than an explicit model. Also, saving and fetching will require you to specify the URL on each model you pass in for that to work. In general, I wouldn't recommend it.

Common model among multiple views

New to WPF. I have a Product model that is an L2S entity. I am creating an application in WPF to edit the product information to potentially replace an old Windows forms app I have. the application has a tab control with a number of tabs on it, such as Packaging, Marketing, Photos, Construction, etc.
My question is how do I structure this in a MVVM system. Do I have a separate view for each tab, each with it's own view model relating to it's particular subset of the Product model? Or do I have a single view with the tab control and all of the fields and a single view model to encompass the model in it's entirety? Or am I going about it completely wrong?
I feel like the first option is the way to go, but then I am also unsure of how to share the same model across multiple view models. Can anyone shed some light on this for me?
--Edit--
Examples of data on the pages:
Marketing has several text fields, and a few subset entity collections such as features, applications, and cross references.
Photos handles a collection of Photos for the product
Packaging and Construction are each a large collection of text fields/combos/checkboxes related to their respective information in the Product
With this minimum of info you've provided I would suggest following solution:
Main ProductView view
Separate View for the each tab
Main container ViewModel: ProductViewModel
For complex tabs separate view model as well. For instance you would have a separate PackagingViewModel so ProductViewModel should expose public PackagingViewModel Packaging property
ProductViewModel should accept all model-related stuff (perhaps some services, model entity, etc) and then initialize all other child view models.

How to make view model and model communicate?

I am using MVVM pattern for my app. The model actually runs a set of test in parallel and keeps tab of the status of the test including its result. I want the status and result to be displayed in the view. I am stuck at desiging the view model.
The problem is that there are lots of classes and sub class hierarchy in the model in which all the required data to be displayed in the view are stored. Those data are dynamic.
I am not sure how to design the view model now.
I was thinking along these lines - Create a new data structure in view model which reflects what is to be shown in the view and get all the view model will dig through the model to get the required data. In this case I am confused how the model will update the view model whenever a data changes. Or how do the model and view model communicate with each other given that the data are stored in different class and sub classes.
Your view model should have references of all models which required to show data on the view. Then view model should handle events from model classes and fire NotifyPropertyChanged event.
If your view is complex and require lots of models, then you can consider to split your view in multiple views and corresponding view model.
You say the user chooses which data to view, so I imagine your VM could hold an array of Models and an index indicating which is the 'active' one, and only communicate with that one.
For that communication, a solution could be to pass to the model an Action to call when new data is available, and that Action would that trigger a NotifyPropertyChanged in the VM. This would work especially well if you make sure only the 'active' model has that Action while in the others it would be null meaning 'don't trigger updates'.

MVC - Where does extra data generated just for the UI get stored?

We are building a Silverlight app and using PureMVC but the technology and framework probably aren't that important to this question.
We have a view that contains a grid and that grid is bound to a model. However, we have additional columns of data that we would like to display for the user but the data is derived and not stored in the model.
Where is the best place within MVC to handle this?
Any help or suggestions would greatly be appreciated!
Thanks a lot,
Bobby
Add properties to your model object for the additional columns then wire up the logic behind them in their property gets and bind them to the grid as additional columns.
From a 'patterns' approach, do not change your model (unless your model already is purposed as a ViewModel. Implement a specific view model in this case. A view model should have view logic (additional columns, code specific to the model layout, etc) a plain model should not.

How to represent 1-to-many relationship in as3.0 data model

I'm building an AS3.0 model for reading from an sqlite database. I've successfully got it working with a simple table. Basically I have a databasemodel class with some shared functions and from it I extend classes, theoretically for each table on the database, but also for 'views' ie combinations of data on different tables when I need to mix things up.
Some of the events have tags stored in a separate table, and I'm wondering about the best way to handle those.. should I include an array in the event class and work with it that way, or separate each tag/cluster of tags into their own class? The tags are predefined and will be edited basically in the same places as if just another property of the event. However many events are imported and can only be edited by changing the tags.

Resources