20 Mar 2011 1:59 PM #1
Model: Lazy loading associated models
Assuming the User->Posts->Comments Model structure described in the Ext.data.Model API entry, I'm wondering how I should fit the pieces together so that my User-store loads no associated models untill one gets selected.
Basically, I want a grid of Users, and a view of Posts and Comments for the selected User, but I don't want to load all the Posts and Comments for all Users in the view.
I'm assuming when I load a User, it will automatically load its associated Posts and Comments from their configured proxies, or can I control when that happens somehow? I see the autoLoad/autoSave config options, but they don't seem to be what I need.
How does that fit with a Users proxy that loads not only users, but Posts and Comments as well? Could I have my users proxy return an empty set of Posts and Comments, so that the Model think it's been fully loaded, and then manually trigger loading Posts and Comments from their proxies when selecting a User?
Would the best solution be to not associate the models in this scenario, and manage the stores programatically, or is there an intended way to configure this sort of thing?
I don't want to autosave anything. But I would like a change to a post, to effectuate marking the User as dirty. (Due to my actual entities consisting of concepts other than users and posts.) That is I would like to select a User, edit/add a post, and then save the User (with his/her posts).
As you can see I'm rather confused on the subject, and any help to clear up how this is intended would be greatly appreciated.
Thanks in advance,
22 Mar 2011 12:57 PM #2
So, I'm wondering if this is getting no replies due to the post length, the question being irrelevant to most people, the topic has allready been answered elsewhere and I should have looked there before posting, no reader has yet had any usefull information to share on the topic, or some other reason?
23 Mar 2011 9:27 AM #3
Heh, sometimes things just don't get answered; I know a few of my posts have been read, but no-one felt like chipping in with any thoughts or a solution
It's an interesting question, since it sounds like a potential solution for how you could build a complex tree store, something which I'm going to attempt shortly...
I can only assume that the association stuff built in to models must allow for what you are asking for.
I can't believe it's only used for consuming a JSON object during a read...
I'll try and have a look into it soon since this sounds like a nice way of approaching a complex tree.
Another thought I had was inheriting from Store and trying to kinda glue several stores together, swapping the tree store depending on your context.
The lack of complex examples for models, stores and trees is a tad frustrating I feel.
23 Mar 2011 11:16 AM #4
To my way of thinking a web application framework isn't complete untill I can have associated entities, and I'm able to populate a master grid, and bind a details form for the models fields, including a child grid for associated models. Furthermore you should have control over when what is loaded, so that you don't have to load more data than you need, which is the topic of my OP. Finally you should be able to configure wether to save the hierarchy on a user action, or automatically with every change.
How these requirements are met by the Ext data framework is rather unclear to me at the moment though. In fact I think answering such questions would benefit a lot of programmers.
By dewie in forum Sencha Touch 1.x: DiscussionReplies: 27Last Post: 25 Feb 2015, 10:03 AM
By babar.sajjad in forum Sencha Touch 1.x: DiscussionReplies: 3Last Post: 31 Mar 2011, 6:56 AM
By michalk in forum Ext GWT: DiscussionReplies: 3Last Post: 13 Oct 2009, 1:12 AM
By Algiano in forum Ext GWT: DiscussionReplies: 1Last Post: 30 Jul 2009, 2:11 PM
By phwaap in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 2 Jun 2008, 4:57 PM