View Full Version : afterRender not firing

18 Oct 2009, 8:06 AM

I'm trying to do focusRow on a gridPanel after the rows are loaded.
This is a list of comments on a support issue (in a Bugzilla-based support system), and this is done to allow direct links to specific comments within an issue, just these forums provide links to specific posts inside threads.

However, I can't get it to fire at the correct time. Having read the discussion regarding the afterRender event (http://www.extjs.com/forum/showthread.php?t=27289&page=4), I tried using afterRender, both on the grid itself and on the top-level container, but no joy. The only event to fire was afterLayout, which fired only after all was rendered AND a resize of the window was done (and only when used for the top-level container). When this happened, focusRow was indeed called and the specified row was displayed.

I need an event that will fire after the grid panel rows are there so focusRow() will work.
Any ideas how to do this ?

Thanks in advance,

18 Oct 2009, 8:11 AM
It's deferredRowRender.

Solution here: http://www.extjs.com/forum/showthread.php?t=74598

Until the viewready event is supported (next release)

19 Oct 2009, 1:42 AM
Hi @animal,

Thanks for your response.
I did this by extending GridView, so I added the viewready event to my extended class rather than extending GridPanel as well in order to add the viewready event to it.

/* Class: Ext.ux.GridViewEx
* Description: GridPanel + event "viewready" fired after afterRender is called
Ext.ux.GridViewEx = function(config) {
Ext.apply(this, config);

Ext.extend(Ext.ux.GridViewEx, Ext.grid.GridView, {
afterRender: function ()
this.fireEvent("viewready", this);
The listening code:

var grid_view = new Ext.ux.GridViewEx({
listeners: {viewready: navigate_to_comment},
var grid =
xtype: "grid",
view: grid_view,

19 Oct 2009, 2:23 AM
Exactly what the suggested solution does. The GridView fires the event through the GridPanel. No modifications to GridPanel are necessary.

It's just easier for client code to attach listeners to the GridPanel because then they don't have to create a GridView - they can allow the automatic default GridView creation to take place.

19 Oct 2009, 3:33 AM
from my quick browsing of the event handling code, I saw that the event has to be added to the class with addEvents:

the code of the fireEvent function does this

ce = me.events[ename]
which requires the given event name to be in the class array of events.

19 Oct 2009, 4:10 AM
It will work. If there's a listener added, the event will be there, if not, it won't fire.