PDA

View Full Version : [CLOSED] Bug DataView click events



aasanchez
1 Dec 2010, 9:50 AM
I have tried to use the click events on the DataView component and they seemed not to follow the description.
click : ( Ext.DataView this, Number index, HTMLElement node, Ext.EventObject e )

the index is not being passed and the order of parameters seemed to be off.

same for:
dblclick : ( Ext.DataView this, Number index, HTMLElement node, Ext.EventObject e )

However the events for:
mouseenter : ( Ext.DataView this, Number index, HTMLElement node, Ext.EventObject e )
mouseleave : ( Ext.DataView this, Number index, HTMLElement node, Ext.EventObject e )

are correct.

Please advise, thanks!

aconran
1 Dec 2010, 1:22 PM
Have you specified the required itemSelector configuration and is it accurate?

aasanchez
2 Dec 2010, 12:10 PM
Aconran, I have specified an item selector and is accurate. The problem is clear when you inspect the arguments passed to the events.
click events have different arguments than mouse events. All should have the same arguments-->( Ext.DataView this, Number index, HTMLElement node, Ext.EventObject e )

In my code I'm extending Ext.DataView to create my own dataview object.
Here is the code for my events:


this.on('click', this.onClick);
this.on('mouseenter', this.onMouseEnter, this);



//onClick:function(dataView, index, node, e){ //***API documentation doesn't match event parameters!
onClick:function(a, node, c){

//NOT OK
},

onMouseEnter:function(dataView, index, node, e){
//OK
}

Condor
3 Dec 2010, 2:55 AM
DataView already has an onClick method that you are overriding!

You need to use a different name for the method.

aasanchez
3 Dec 2010, 7:46 AM
Condor,
You were right about me overriding the onClick method, however I still think there is a problem. Once I remove my onClick method and I change the name of the method something weird happens. Here is my test code


this.on('click', this.onItemClick, this);
//...

onItemClick:function(dataView, index, node, e){
console.dir('Data View: '+ dataView);
console.log('Index: '+index);
console.dir('Node: '+node);
console.dir('Event: '+e);
},


and here is what I get on my console:



Data View: [object HTMLDivElement] //bad
Index: 4 //good
Node: [object Object] //bad
Event: undefined //bad

Data View: [object Object] //good
Index: 4 //good
Node: [object HTMLDivElement] //good
Event: [object Object] //good


As you can see my function is printing 2 consecutive calls returning different objects every time. The last one printed are the correct arguments, the first one is not (besides the index).
Shouldn't just print the correct arguments for the 'click' event.
Thanks.

Condor
3 Dec 2010, 7:59 AM
You are very good at choosing bad function names! "onItemClick" is also already defined by DataView.

aasanchez
6 Dec 2010, 7:18 AM
I guess I am :)

After choosing a better name the event returned the expected parameters. Thank you!