PDA

View Full Version : grid callback not showing totalrows



pomata
1 Dec 2006, 5:29 PM
Jack,

when using this


// params can be url encoded string or an object
var params = {'author': author};
// use callback to clear loading indicator
this.dataModel.load('/blog/examples/amazon.php', params, this.clearIndicator);

the if I put

this.dataModel.getTotalRowCount()

in the callback function, returns zero.

I am currently using my onload delegate.... in order to know number of rows and display a message....

Would be nice to have it in callback.... unless u tell me it is not intended.

Regards

P

Animal
1 Dec 2006, 11:39 PM
In AbstractDataModel.load() it says:

* callback : Function
(optional) Callback when load is complete - called with signature (this, rowCountLoaded)


But in LoadableDataModel.loadData, it is called like this:



if(typeof callback == 'function'){
callback(this, true);
}

jack.slocum
2 Dec 2006, 4:52 AM
The docs are wrong. It calls with true for success, false for failure. It always has. Unfortunately since it's been like that since the beginning, changing it isn't really an option.

If you are getting zero back on that call (getTotalRowCount) then there is something wrong somewhere else. Can you post more code?

pomata
2 Dec 2006, 7:20 AM
Jack, I am using your code

http://www.jackslocum.com/blog/2006/08/31/a-grid-component-for-yahoo-ui-part-2/

then in my call back function this.clearIndicator I just


alert(this.dataModel.getTotalRowCount());

I´ve modified to use

this.dataModel.onLoad.subscribe(this.onLoad.createDelegate(this));
and then get the rowcount on the onload..... like that it works...

Regards

please note, if you test it, it will actually return the previous totalrow... so if you don´t populate grid on load then it returns zero, otherwise number of rows for previous data load.