-
19 Jul 2012 4:11 AM #1
Unanswered: Generate map on detailcard of nestedlist out of a store
Unanswered: Generate map on detailcard of nestedlist out of a store
I have a nestedlist with some items in it coming from a tree store.
Now when i click on "So kommen Sie zu uns" i want to open a detailcard that has a map on it. The address for the map is in the store.
All other items just open the detailcard and get the html content out of the store.
Can i do it this way (and how?), or is there another different better approach?
CaravansMap.png
Here is my nestedlist:
Here my controller code:Code:Ext.define('App.view.Service', { extend: 'Ext.dataview.NestedList', xtype: 'service', id: 'mainlist', requires: [ 'App.store.Service', 'App.view.ServiceDetail' ], config: { title: 'Service', useTitleAsBackText: false, backText: 'Zurück', onItemDisclosure: true, store: 'Service', detailCard: { xtype: 'servicedetailcard' }, zIndex: 0 }, getTitleTextTpl: function() { return '<div>{name}</div>'; }, getItemTextTpl: function(node) { return '<div><strong>{name}</strong></div>'; } });
servicedetailcardCode:onServiceDetailCardActivate: function(card, list) { // Get selected leaf node var record = list.getLastNode(); // Get and update description var descriptionField = card.down('#servicedescription'); descriptionField.setHtml(record.get('description')); },
store json fileCode:Ext.define('App.view.ServiceDetail', { extend: 'Ext.Panel', xtype: 'servicedetailcard', id: 'servicedetailcard', config: { scrollable: true, defaults: { styleHtmlContent: true }, items: [ { id: 'servicedescription', html: '' }, ] } });
Code:{ "items": [ { "id": 1, "name": "Über uns", "description": "<a href='#'>test</a><p>Lorem ipsum dolor sit</p>", "leaf": true }, { "id": 2, "name": "Was wir machen", "description": "Lorem ipsum dolor sit", "leaf": true, }, { "id": 3, "name": "Werkstatt", "description": "<h1>Werkstatt</h1>", "leaf": true }, { "id": 4, "name": "So kommen Sie zu uns", "description": "", "address": 'Berliner Platz 8, 48151 Münster, Germany', "leaf": true }, ] }
-
21 Jul 2012 12:11 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,657
- Vote Rating
- 435
- Answers
- 3109
If you have the detailCard provided the nestedlist should automatically go to it but do nothing more than set it as the active item. You need to listen to the leafitemtap event on the nestedlist to take action when a leaf has been tapped on. The nestedlist example that comes with ST2 shows this.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
22 Jul 2012 11:54 PM #3
Thanks for your answer Mitchell, but i don´t know what to do now.
My list is working and shows detailcards for every item. I update the contents with
So i need to change the event to leafitemtap? And then? How to add an xmap only to the fourth item of my store? I hope someone can help.Code:serviceDetailCard: { activate: 'onServiceDetailCardActivate' }, onServiceDetailCardActivate: function(card, list) { // this needs work. Display a map when no content is given. // address should come out of store // Get selected leaf node var record = list.getLastNode(); // Get and update description var descriptionField = card.down('#servicedescription'); descriptionField.setHtml(record.get('description')); },
-
23 Jul 2012 12:15 AM #4
If
current record . get( 'address' ) !== ''
Then
container add {xtype:'map'}
To se the address and center the view. read docs and docs
http://docs.sencha.com/touch/2-0/#!/...cfg-mapOptions
https://developers.google.com/maps/d...dressComponent


Reply With Quote