I just started with Ext recently and had a horrible time trying to figure it out. I've posted (complained - lol) several times about the lack of a real demo that shows CRUD in the MVC architecture.
Finally, I have put together a small sample myself.
Gets some input from others about all the things that are wrong in it!
Helps others start with Ext.
If you have feedback on it, please be constructive. Again, this is my first real stab at Ext.
NOTES :
You need PHP to run this sample. Why? Because I used PHP for the server side and sessions to maintain customer lists while playing.
The "Vendor" section of this does very little. I just built out CRUD for the Customer section. The vendor section is just to show what multiple tabs would look like in the Center region.
Thanks, and finally we have something 'real'! Hope you will fix and develop this sample to use more and more widgets and other Ext capabilities further.
It would be great if one of the official MVC demos were a port of the "TKE" sample app from Chapter 16 of Jesus' "ExtJS In Action" book.
It's large enough to be non-trivial, but not too large. This would also be a great way to contrast the new 4.0 MVC patterns/idioms/api with the well documented 3.0 implementation from the book.
Any samples you build should also explain the design choices and the differences from 3.0.
Duplicating models for each CRUD operation doesn't really seam like the best way though ? Is that really Sencha's suggested best practice Ed ? Its certainly not DRY (aka duplication is evil) and if it is the suggested practice indicates a flaw in the Ext4 data architecture.
The only major differences are that the edit model has some extra fields, and the attached proxies all use different URLs.
It looks like with a REST proxy (Ext.data.proxy.Rest) it should be possible to use the same resource URL for add/edit/delete/get and list. I.e. use of the HTTP verbs GET, POST, PUT, DELETE.
With optional fields (e.g. for add vs edit) and view configurations (e.g. only showing some of the model's fields in a grid with Ext.data.Panel columns config) and so forth it should be completely fine to share the model between all the CRUD operations ?
Is there a good reason to separate models into AddModel, EditModel, ListModel etc? Just to me it seams you would end up duplicating field definitions and possibly validations etc.
Is that really Sencha's suggested best practice Ed ?
Thanks for the input. This is certainly not an example of Sencha's best practices. This is simply my first stab at an MVC example with Ext. It's my first Ext JS application ever. I put this out there because I could not find a decent example to learn from. So, I'm hoping input such as yours will help myself and others to learn.
With optional fields (e.g. for add vs edit) and view configurations (e.g. only showing some of the model's fields in a grid with Ext.data.Panel columns config) and so forth it should be completely fine to share the model between all the CRUD operations ?
I actually considered doing exactly that initially. However, keep in mind this is a somewhat simplified example. The Grid Panel is simply there to be a list of customers. Imagine there are 50, 100, or 250 in the list. How much sense does it make to transmit the address details for 500 customers just to populate the list JUST IN CASE one of them is clicked on to have their details viewed/edited?
With a more complex example, the edit customer tab would not be the only result of clicking on a customer. You might have a tab to see their orders, see their trouble tickets, etc. Surely you don't want a single model that loads all that info at once just to avoid having a model, controller, and store for Orders, TroubleTickets, SubscriptionPreferences, etc.