-
8 Jan 2013 1:46 PM #1
Reusing Data Store used for showing map
Reusing Data Store used for showing map
Dear All,
I have 2 google maps with same coordinates data.
One is shown on tab panel and one is shown on a window (side by side).
The store "geostore" is a json store and is loaded on tab panel ("afterrender event").
Now I want to call the same store and show coordinates on window.
But I am stuck how to procede this.
Please shed some light on it.
thanks
-
8 Jan 2013 7:46 PM #2
so you have two maps, one on a tab and other on a window. You want both maps to show the exact same data? If so, just populate your maps using the same store. I'm guessing we're not talking about the same thing... let me know.
John
-
8 Jan 2013 8:57 PM #3
hi,
I want to call the same store but I dont want to reload the store. so which method I need to see the data on the store (or model) I can't find proper solution. let me know if it is possible.
thanks
-
9 Jan 2013 6:43 AM #4
If both of your maps show the same coordinates then why not use the same store? After the store is loaded the first time (map 1) , it doesn't need to be loaded again unless you want the stores data refreshed or you need to change the filter back on the server. You can re-use a store as many times as needed w/out ever reloading.
If we're not talking about the same thing then please provide more detail regarding what data is shown on your maps.
John
-
9 Jan 2013 7:27 AM #5
Thanks,
I exactly want that but I dont know how to do that
Can you share some codes
thanks
-
10 Jan 2013 10:30 AM #6
My code is like this:
On the main viewport afterrender event I am loading my store like this
This is working absolutely fineCode:var geoCoordinates=Ext.create('MyApp.store.coordinateStore',{});geoCordinates.load({ scope: this, callback: function(records, operation, success) {........}})
but I don't know how to use MyApp.store.coordinateStore without reloading the data. Which method I need?
Please help me through it.
thanks
-
10 Jan 2013 11:32 AM #7
simply grab your store this way ....
the first time you load the store (in your code example) it contains data. Now all you do is grab a reference to that store. You can do anything store related to the myStore variable. Assign it to a list, loop over it ... whatever. The store is global to your application.Code:var myStore = Ext.StoreManager.get('coordinateStore');
The Sencha store docs have all the details
Hope that helps
John
-
10 Jan 2013 11:50 AM #8
Dear BostonMerlin,
I already tried it. But chrome's developer tool is not showing any data. I am confused what wrong I am doing.
I simply did something like.
Code:var myStore = Ext.StoreManager.get('coordinateStore');//Var recd= myStore.getAt(0); console.log(recd);
and the result is undefined. I cannot understand why.
I have skimmed through the documentation too.
Please help me out.
thanks
-
10 Jan 2013 12:10 PM #9
It looks like you're creating the store on the fly which is ok if you never want to use it again but in your case you need to define this ahead of time. You should instead be following best practices by creating your stores and models up front and referencing them in your applications config. Once you do that, you'll be able to grab a reference to the store after the first call is made.
Alternatively, once you've created your store (on the fly), pass that store variable to the function (or better yet, controller action) that will then use that store to update your second map. I would instead create your store up front then reference as needed but at least you know you have a few options.
Your questions indicate you've not gone through the basics of building a touch application. You might want to work through the examples supplied by Sencha.
Getting started:
http://docs.sencha.com/touch/2-1/#!/guide
Hope that helps
John
-
10 Jan 2013 12:19 PM #10
Dear BostonMarlin,
Thanks I think my problem is solved now.
The store being local was the problem.
Thank you


Reply With Quote