-
18 Feb 2013 12:19 AM #1
Answered: Controller: for every List 1 function?
Answered: Controller: for every List 1 function?
Hello,
I got a list like this with always 4 items:
In my controller, I had only one event for the entire list(myList).Code:xtype : 'mylist' config : { type : 'vbox', onItemDisclosure : true, fullscreen : true, store : 'MyStore', itemTpl : [ '{name} : {value}' ] }
But I want to disclose an item and the controller shows me a specific list(listA, listB...), depending on where I click on it.
Is there any possibility to do it like this? (just an example)
Code:control : { myList: { disclose(FirstItem): 'showListA', disclose(SecondItem): 'showListB', disclose(ThirdItem): 'showListC', disclose(FourthItem): 'showListD' } }
-
Best Answer Posted by Isnogud
-
19 Feb 2013 9:01 AM #2
Yes, but what you'd have to do is add logic in to your itemTpl that outputs a specific parameter / attribute for each of the four lists, and then you could use that in your control / ref selector in the controller.
It's probably easier just to have one main event listener, and in that listener, query the parameters / attributes of the item on which the event was fired. Then proceed from there.
-
20 Feb 2013 1:37 AM #3
I did it like this:
Code:var selectedView = ''; switch (record.fullName()) { case 'ListA': selectedView = 'lista'; break; case 'ListB': selectedView = 'listb'; break; case 'ListC': selectedView = 'listc'; break; case 'ListD': selectedView = 'listd'; break; } this.getMain().push({ xtype : selectedView, title : record.fullName() });I know it's probably not the best solution but I'll improve it soon.Code:fullName : function() { var d = this.data, names = [ d.name ]; return names.join(" "); }
-
20 Feb 2013 2:39 AM #4Sencha Premium Member
- Join Date
- Feb 2012
- Location
- Berne, Switzerland
- Posts
- 584
- Vote Rating
- 32
- Answers
- 35
I usually do this like that:
Then in my controller I listen for the itemTap and itemDisclose event on that list and push the selected view into a navigation view:Code:xtype:'list', title: 'View Selector', onItemDisclosure: true, store: { data: [ { title: 'ListA', xtypeToLoad: 'lista' }, { title: 'ListB', xtypeToLoad: 'listb' }, { title: 'ListC', xtypeToLoad: 'listc' }, { title: 'ListD ', xtypeToLoad: 'listd' } ] }, itemTpl: '{title}'
Code:onItemDisclose: function(list, record, target, index ) { this.onItemTap(list, index, target, record); }, onItemTap: function(list, index, target, record) { var title = record.data.title, viewToPush = record.data.xtypeToLoad, navigationView = list.up('navigationview'); navigationView.push({ title: title, xtype: viewToPush, data: record.data });
-
20 Feb 2013 2:49 AM #5
-
20 Feb 2013 2:03 PM #6


Reply With Quote