PDA

View Full Version : Grid & XMLDataModel and load event



dodge
2 Feb 2007, 6:26 AM
Hello!
I created grid


....
logGrid = new YAHOO.ext.grid.Grid("grgr", dataModel, colModel);
logGrid.getDataModel().on('load', logGridLoadHandler);
logGrid.render();
....

Documentation says about load event "Subscribers will be called with the following parameters: * this : DataModel"...
But in LoadableDataModel there is


fireLoadEvent: function(){
this.fireEvent('load', this.loadedPage, this.getTotalPages());
},

So load event handler is called with loadedPage and totalpage arguments! Is it ok or this is bug in yui-ext/my code?

I need to change loadedPage property after data comes in DataModel from remote url and before data is displayed in grid. I need such functionality to make jump in particular grid page. But this page number is known only when data are received from URL.

SLerman
7 Feb 2007, 1:46 PM
I just encountered this problem, and it would definitely be nice to fix, especially since the current page and total number of pages can be retrieved from the DataModel object anyway. The internal load handlers need those two parameters (I couldn't find this handler in the code to modify it), but you can add a third. If you're using the full Javascript package, the line you want to modify is source/data/LoadableDataModel.js:265. You can just add this to the fireEvent call. If you're using a single compressed file, search for fireLoadEvent:function(){this.fireEvent('load',this.loadedPage,this.getTotalPages());}.[/i]

dodge
8 Feb 2007, 12:13 AM
I just encountered this problem, and it would definitely be nice to fix, especially since the current page and total number of pages can be retrieved from the DataModel object anyway. The internal load handlers need those two parameters (I couldn't find this handler in the code to modify it), but you can add a third. If you're using the full Javascript package, the line you want to modify is source/data/LoadableDataModel.js:265. You can just add this to the fireEvent call. If you're using a single compressed file, search for fireLoadEvent:function(){this.fireEvent('load',this.loadedPage,this.getTotalPages());}.[/i]
Yeah I already came to this solution by adding third argument for handler. It seems that loadedPage and totalPages were artificially added when paging toolbar was added. The reason by doing so is that paging toolbar needs these two arguments to set correct current page and total pages when new page is loaded. It's implemented by adding function onPageLoaded (pagedGridView.js function plugDataModel)
dm.on('load', this.onPageLoaded, this, true); in datamodel load event chain. I suppose this is main problem why load event is called with these two parameters but not with DataModel.