I'm confused about to how to properly use Models/Stores/Proxies/Readers in ExtJS 4. I've read the guides and looked at the examples, but still can't see the solution to my problem.
Goal: Say I am working with car
objects (for which a model exists), which contain (among other things):
- Car identifiers (VIN#, Make, Model, Year, Color, ect)
- Ownership history
- Maintenance history
- Detailed list of car components (engine: {L-Twin cylinder, 2 valve per cylinder Desmodromic, air cooled}, front brake : {}, ...)
And assume I'm using the VIN# as a primairy key, and that I have a RESTfull API setup like
GET /car // gets list of cars
GET /car/123abc // gets car with VIN# 123abc
Now, if I have a reference to a VIN# in a controller, what I want to do is launch a complex dashboard that may have components like:
- A grid for the car components
- A chart for maintenance costs vs time
- A custom panel for displaying the Make, Model, Year
- ect
Problem:
Say I have a Car
model, and a CarComponent
model, where my server is configured to send nested data (i.e. no API for dealing directly with CarComponent
's). Ideally... I just want to request the car data from the server with a simple GET /car/<the vin #>
and use the returned data to populate all the components of the complex dashboard. So my attempt strategy is:
- Models:
Car
,CarComponent
- Stores:
Cars
- Proxies: a single rest proxy attached to the
Car
model - somehow use nested properties of a
Car
to fill the components (ex. the grid of components)
Or do I need separate stores for the components? Also, I can't tell how the Stores work; I don't want to load all cars from the server.. just the specified one. I'm just confused on how to string together the models/proxies/stores to accomplish what I need...