PDA

View Full Version : Get component which triggered the event (render function)



rkaat
8 Sep 2010, 2:16 AM
Hey,

I am trying to configure 1 function for several grids. The function is called when the grid renders. Now, I would like to now which component(grid) triggered the function, so I don't have to write a function for each grid.


//Gridpanel (got several of these in my app which all call the same function: setTip)
new Ext.grid.GridPanel({
...
listeners{
render : setTip
},
...
});

//Function
function setTip(){
var grid = ..... //Grid which triggered the event
}
Is there a way to get the component which triggered the event ?

Animal
8 Sep 2010, 2:19 AM
According to the API docs, what parameters is a render event handler passed?

rkaat
8 Sep 2010, 3:26 AM
The container is passed, according to the API docs. But I have to make a big change anyway, because my gridpanel is positioned in a panel. So, I would have to replace my render listener, with something else.

Condor
8 Sep 2010, 3:38 AM
No, you are looking at the render() method. The render event only has a single parameter 'this'.

rkaat
9 Sep 2010, 12:35 AM
Ok, I got 2 grids which both render when I refresh my page. They both call the same function to show a tooltip. Only the last rendered grid is showing me tooltips.

Can I use the render event when I got multiple grids, or should I take another event like: mouseover (tried mouseover, but can't retrieve the grid from the eventobject)?

Animal
9 Sep 2010, 1:02 AM
You don't usually call a function to show a tooltip. You create a tooltip with a target, and then it sets itself up to show on mouseover of the target.

So you mean call the same function to CREATE their tooltips.

OK. Here's the ANSWER to your question:

Looking at the API documentation for the render event, what parameter is passed to the handler?