PDA

View Full Version : Ext.List : Pass record data to controller without using onItemDisclosure



won.rhee
2 Aug 2011, 3:43 PM
Hello All,
It's probably something simple, but cant seem to figure it out.
I have a Ext.List with listeners that dispatches to controller.
If I have onItemDisclosure, I can pass data to controller like this :



.....
this.list = new Ext.List({
store: this.store,
itemTpl: '{StoreCode} : {Name}<br><div class="address">{City}, {State2Code}, {Zip}</div> {distance} mi',
grouped: false,
onItemDisclosure: function(record){

Ext.dispatch({
controller: 'AFC',
action: 'test',
data: record.data

})
}

});
......


But I do not want to use onItemDisclosure. How can I use listeners/onItemTap/itemtap/ or select to pass data to controller?

So I want to do something like following but pass record.data to controller :


.....
this.list = new Ext.List({
store: this.store,
itemTpl: '{StoreCode} : {Name}<br><div class="address">{City}, {State2Code}, {Zip}</div> {distance} mi',
grouped: false,
listeners: {
select: function(record){
Ext.dispatch({
controller: 'AFC',
action: 'test',
data: record.data

})
}
}
});
......


What can I do?

mitchellsimoens
3 Aug 2011, 4:39 AM
There is an itemtap event.

won.rhee
3 Aug 2011, 8:27 AM
There is an itemtap event.

Thanks for that. So below code will at least pass tapped data but wondering there's a better way:



.....
listeners:{
itemtap: function(dv, idx, itm, e){
var tapData = dv.store.data.items[idx].data;
Ext.dispatch({
controller: 'AFC',
action: 'test',
data: tapData

})
}
}
.....

mitchellsimoens
3 Aug 2011, 8:28 AM
I would use the getAt method on the store:


dv.store.getAt(idx);