PDA

View Full Version : Detecting and canceling an Ext.List select



miroperez
18 Feb 2011, 12:31 PM
I have an Ext.List which when you select an item it has a "itemtap" listener that loads another panel with detail data. I haven't been able to figure out how to cancel the itemtap if the user clicks the currently selected item. Right now the default is the item deselects itself. I want it to remain selected and not fire the itemtap because I don't want to incur the hit to load (remote data) the panel data again.

I tried the beforeselect listener and that never seems to be fired as I put console.log stmts in there and I never see them. The selectionchange event is too late in the process I think.

Maybe the Ext.List isn't the most appropriate widget for this? Saw that the kitchensink example uses NestedList and for some single level items it has the behaviour I'm after but I was just wondering if there was a way to do it with the Ext.List. This is a fairly short list most likely under 12 items.

arthurakay
18 Feb 2011, 2:13 PM
Since you're already using the "itemtap" event, why not handle the logic for selecting/deselecting and loading in the event handler?



...
listeners: {
'itemtap': function(thisView, index, item, eventObj) {
//if item is already selected
//do something

//else
//load your panel
}
}
...


I don't know how you have your app structured, so if that doesn't work post some code and I can try to help you find a better solution.

miroperez
18 Feb 2011, 2:32 PM
I started to do that and the problem is the state has already changed in the selection model so I don't know if I'm clicking on another item or the same item. I suppose I could add some state to the list of what was previously selected but that didn't seem like I'm just working around something that might be not so obvious. The beforeselect event looked promising but it never fires.