PDA

View Full Version : Grid rowselect triggering another grid load



vaduros
19 May 2007, 8:16 AM
I'm working on an application where I've added an event listener to the row selection model of a grid


var rsm = new Ext.grid.RowSelectionModel({singleSelect:true});
rsm.addListener('rowselect',
function (grid, rowIndex, e) {
ra = nstore.getAt(rowIndex);
fnum = ra.get(cm.getDataIndex(0));
mwert = ra.get(cm.getDataIndex(3));
showDetails(fnum,mwert);
});

When this grid, the 'parent' grid is loaded or the ds of the grid is modified, this event is trigger and loads another grid, the 'child' grid, via the showDetails function. showDetails just renders the 'child' grid and loads its own ds the the first time it is invoked or just loads its ds on subsequent calls.

What I can see using firebug is that the load method of the 'child' grid fires several POST requests to the ds script (dfget.php) until the 'parent' grid is finally rendered. It seems as if the data source script is blocked from sending data until the rendering of the 'parent' grid has finished (both grids use the same ds script with different parameters). That doesn't make sense to me. We DO deal with asynchronous requests here, don't we? And when I look into the server log, I can see that in fact only ONE POST request has happened (or maybe finished), even when firebug reports several tries.

I've attached a screenshot from firebug. At the point in time where the arrows point to, the ds script has finished sending the JSON data for the 'parent' grid, but the ds of the 'child' grid is still trying to get JSON data from the ds script.

Anybody with an explanation for this behavior?

jsakalos
19 May 2007, 9:39 AM
I do not have the exact explanation of this but I have some experiences with data stores and asynchronous jobs that might be of a value to you:



I don't know why, but Firebug is not very reliable to count requests really sent. I have also noticed that I had tab Response "Loading..." forever like if server wouldn't respond without any further consequences. Application runs as it should and no errors are reported. I've decided just to ignore it but I don't want to discourage you to investigate this behavior deeply.
This asynchronous nature of Ext is beautiful thing but on the other had one has to be aware that if he executes ds.load() the data won't be available in next statement. I went through several trial and errors on the matter. Now I have sometimes 3 (or more?) levels of onReady-like event handlers and everything's working. Funny part of it is that if you put a firebug's breakpoint one line after the above mentioned ds.load execution stops there but request is made in the background and data is loaded. This fooled me many times when app ran fine while debugging but it didn't otherwise.

Hope this may help.