PDA

View Full Version : Trteestore issue



fsjay
16 Aug 2011, 5:15 AM
I'm new Sencha Touch and created an app that needs multiple maps with different locations on each.

I used a liststore to have multiple cards to display each map:



WashingtonPlaces.liststore = new Ext.data.TreeStore({
model: 'ListItem',
root: {
items: [
{
text: 'American Philosophical Society',
card: {xtype: 'map1card'},
leaf: true
},
{
text: 'Battle of the Assunpink Creek',
card: {xtype: 'map2card'},
leaf: true
},
{
text: 'Battle of Brandywine',
card: {xtype: 'map3card'},
leaf: true
},
{
text: ' Battle of Monmouth',
card: {xtype: 'map4card'},
leaf: true
},
{
text: 'Battle of Princeton',
card: {xtype: 'map5card'},
leaf: true
},
....



And then I have a separate view file for each map.



WashingtonPlaces.views.Map1card = Ext.extend(Ext.Panel, {
id: 'map1card',


initComponent: function () {

var position = new google.maps.LatLng(40.3,-74.8734);


var infoBubble1;


this.map = new Ext.Map({
mapOptions: {
center: position,
styleHtmlContent: true,
zoom: 12,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.DEFAULT
}
},
listeners: {

maprender: function (comp, map) {

if (navigator.geolocation) {
....

Ext.reg('map1card', WashingtonPlaces.views.Map1card);





But I know there is a better way, but not sure how to do it. Is there a way to just pass in values to one view file so I can reuse it?

Thanks in advance.