PDA

View Full Version : How can I duplicate a store/model when creating a tree & grid?



DavidThi808
26 Aug 2013, 2:45 PM
Hi;

I'm asking here because I need to know how to do this in Architect (easy if not using Architect). I have both trees and grids where I change the store url and the model fields on the fly based on what a user enters. I'm presently doing this to the initially created store/model (in Architect). The problem with that is when I create another instance of the same window, then all the trees/grids in it are showing the data from the previous use instead of being empty.

How can I duplicate the store/model for a tree/grid when it is first created? Or is there a better way to do this?

thanks - dave

jminnick
27 Aug 2013, 5:26 PM
So you want to use a single store in multiple places but when one updates the others do not?

DavidThi808
28 Aug 2013, 7:36 AM
I think what I want (I may not understand the best way to do this) is each time I create the tree/grid, I create a duplicate of the store/model for that tree/grid and assign that duplicate to that instance. That way the original store/model is not changed and when I create another instance of the tree/grid, it duplicates that original store/model.

??? - thanks - dave

jminnick
28 Aug 2013, 8:06 AM
I think what I want (I may not understand the best way to do this) is each time I create the tree/grid, I create a duplicate of the store/model for that tree/grid and assign that duplicate to that instance. That way the original store/model is not changed and when I create another instance of the tree/grid, it duplicates that original store/model.

??? - thanks - dave

Have you thought about base-lining the data on the server side; then when you need to create another store, making a trip back to the server to retrieve it? You could have all of that managed in a controller.

DavidThi808
28 Aug 2013, 8:18 AM
Have you thought about base-lining the data on the server side; then when you need to create another store, making a trip back to the server to retrieve it? You could have all of that managed in a controller.

Hi;

I'm not sure what you mean by that. But two things to keep in mind for our case, with each instance of the tree/grid, the model changes and the url to get the data changes. So it's not just different data.

thanks - dave

jminnick
28 Aug 2013, 8:28 AM
I just mean; as opposed to trying to duplicate and change properties... request the data again and create new stores with new properties.

DavidThi808
28 Aug 2013, 8:51 AM
I just mean; as opposed to trying to duplicate and change properties... request the data again and create new stores with new properties.

Ok. But how do I do that? Architect has everything nicely wired up so on a getStore().loadPage(1) call, it requests the data and loads it in the grid. And I like that. Once I have it all set up with the specifics for a given url and model, everything is just a call.

Where/how do I create a new store and model to do this? No data, just the empty store & model.

thanks - dave

jminnick
28 Aug 2013, 8:56 AM
Ok. But how do I do that? Architect has everything nicely wired up so on a getStore().loadPage(1) call, it requests the data and loads it in the grid. And I like that. Once I have it all set up with the specifics for a given url and model, everything is just a call.

Where/how do I create a new store and model to do this? No data, just the empty store & model.

thanks - dave

I'd code it in a controller. The only thing you'd really lose is visibility in the Inspector.

DavidThi808
28 Aug 2013, 9:01 AM
I'd code it in a controller. The only thing you'd really lose is visibility in the Inspector.

Ok, I'm totally lost. Do what exactly (ie what method call to duplicate a store/model) in the controller. Call it when? From where?

jminnick
28 Aug 2013, 9:42 AM
Ok, I'm totally lost. Do what exactly (ie what method call to duplicate a store/model) in the controller. Call it when? From where?

assignedStore = Ext.create('MyApp.store.AssignedServers');

DavidThi808
29 Aug 2013, 1:53 PM
Where do I call that code? And if you say in a controller, where do I call the controller? The problem is this should be done in the constructor, but Architect doesn't let me put code in the constructor.

So where/how do a call the controller or function or write code to assign the new store object?