-
20 Sep 2010 2:26 AM #1
Simple List with Dynamic Card
Simple List with Dynamic Card
I was wondering what the best way to approach this would be.
I have a list and clicking an Item in the list will display a new card populated with that entries details. I realise this is VERY simplistic but I am not sure what I should be doing. Do I use a card layout with the list as the first card and apply values to the second card on click? Or do I place a card over the list?
James
UPDATE: I should learn to read. Sorry.
http://www.sencha.com/forum/showthre...tural-ApproachLast edited by ksystems; 20 Sep 2010 at 2:28 AM. Reason: I can;t read
-
20 Sep 2010 2:32 AM #2
Code:Ext.setup({ onReady: function(){ Ext.regModel('Person', { fields: ['first', 'last', 'age'] }); var store = new Ext.data.Store({ model: 'Person', data: [{ first: 'John', last: 'Doe', age: 25 },{ first: 'Mary', last: 'Smith', age: 26 }] }); var main = new Ext.Panel({ layout: 'card', fullscreen: true, items: [{ itemId: 'list', xtype: 'list', store: store, itemSelector: '.person', tpl: '<tpl for="."><div class="person">{first}</div></tpl>', listeners: { itemtap: function(list, index){ var detail = main.getComponent('detail'), rec = store.getAt(index); detail.update(rec.data); main.setCard(detail); } } },{ itemId: 'detail', tpl: '{first} - {last} - {age}', dockedItems: [{ xtype: 'toolbar', dock: 'top', items: [{ text: 'Back', handler: function(){ main.setCard(0); } }] }] }] }); } });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
20 Sep 2010 10:22 AM #3
Evan, thanks for the code.
How would you approach this if you were loading each card dynamically from a local html file, the way that jQT does with local links to html files?
Essentially, I want to port my existing list/card architecture app to Sencha, so that it works the same as it did with jQT, but with the more native-acting header/toolbar that Sencha offers.
Thanks!
-Michael
-
15 Oct 2010 2:36 PM #4
Hi,
I am working on a project with the same functionality. The sample code provided is very simple and not database driven. In the sample code, the detail list was already populated with the data from the model i.e. {first}, {last}, and {age} upon initialization. I would like to populate the detail list dynamically with the data from the data source only when the user taps the itemtap of the list. I mean, upon item tap event of the list, a particular id will be retrieved from the tpl e.g {id} and passed to the url for getting the related data from the data source and populate the detail list. How should I solve the problem. Any help would be very much appreciated. \
Currently I am using Jsonstore and got no problem filling up the first list with data. Actually, I would like to create another list upon itemtap event. Is that possible?
Many Thanks.
-
15 Oct 2010 3:22 PM #5
To pull in HTML code into your Sencha Touch App you can use contentEl: 'divID' as a parameter for the element you want the html to go into. Sencha basically uses a single HTML file, so to go that route you would have to have your content in the same index.html with class="x-hidden-display" on each of the parent div elements. Alternatively you might be able to do an ajax request to your root location to pull in html files, for native apps in phonegap it's something like file:///android_asset/www/ while a web app would be the obvious. I haven't tried it, so YMMV.
-
15 Oct 2010 3:26 PM #6
What I do in my projects is have one list populated by a store where you select an item, an ajax request goes out, the viewable card is switched to the next card, the 2nd store's data is dumped so the list appears empty (ex: BT.store.Friends.loadData({})
, while the json data is being fetched and when it comes back it populates the 2nd store for the 2nd list, and the list updates automatically.
-
15 Oct 2010 4:27 PM #7
Hello Mike,
Thanks a lot for your suggestions. It would be clearer indeed if you could please show me some working sample codes since I am stuck with this 3 three days now.
Thanks so much for your help!
-
15 Oct 2010 7:13 PM #8
Helllo,
By the way how do I update the 2nd store after the ajax call returns the new data from server? something like store2.update(newdata) or something else? And where should i dump the 2nd store data so the list will be empty initially? Many Thanks.
-
16 Oct 2010 2:07 AM #9
-
28 Oct 2010 6:51 PM #10
Mind posting the code you found? This thread is pretty helpful and that would be a good way to wrap things up.
Thanks!
Similar Threads
-
Adding static panel and list on the same card
By robertj98 in forum Sencha Touch 1.x: DiscussionReplies: 5Last Post: 19 Jul 2010, 7:27 AM -
Inserting a List in a TabPanel Card
By nobosh in forum Sencha Touch 1.x: DiscussionReplies: 10Last Post: 8 Jul 2010, 11:50 AM -
Wizard (card) dynamic content generation with XmlStore, Best Practices & How-To
By gkaplan in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 10 Jun 2010, 11:41 AM -
[OPEN] [FIXED-97][3.0RC3] Combo in modal window with card layout doesn't show list
By deanna in forum Ext 3.x: BugsReplies: 13Last Post: 30 Oct 2009, 12:44 PM -
ComboBox with simple JSON List
By H.Morch in forum Ext GWT: DiscussionReplies: 0Last Post: 17 Sep 2009, 5:54 AM


Reply With Quote
