PDA

View Full Version : store afterload event???



cs01rsw
2 Aug 2010, 8:27 AM
Hi,

we see so many occasions where a store needs an afterload event but there doesnt appear to be one that works!

We have seen on ext documentation that the load event has a callback function but it doesnt appear to work. we try to use the callback in the following way:

grid.store.reload( {callback : function(){alert("")}}), which does not work
grid.store.load( {callback : function(){alert("")}}), which does not work

or in when the store is declared:

listeners: {'load' : {callback: function(){alert(""}}}, also does not work

thanks

j-joey
2 Aug 2010, 10:11 AM
try this:


grid.store.on( 'load', function( store, records, options ) {
alert( 'succesfully loaded' );
} );

darthwes
2 Aug 2010, 4:56 PM
The code you posted should work. I hate alerting "", but I think it should work. The listener approach also _should_ work (unless you have some wierd class hierarchy that overloads/deletes the listeners). Are you sure you're "load" is finishing? You might want to



var store = {
...
listeners: {
exception: function(misc) {
alert("Holy cow, we're getting an exception!");
}
}
};


check to see if you're getting some kind of load exception.
Let me know what you find out. Hope this helps.
That help?

cs01rsw
3 Aug 2010, 6:30 AM
no exception is being thrown...

we tried the load event which works:

listeners: {
load: function(){alert("success");},
exception: function(misc)
{
alert("Holy cow, we're getting an exception!");
}
},

however when we use the callback as follows:

listeners: {
load: {callback: function(){alert("");}},
exception: function(misc)
{
alert("Holy cow, we're getting an exception!");
}
},

we get an error:

l.fireFn.apply is not a function
[Break on this error] if(l && l.fireFn.apply... me.obj || window, args) === FALSE) {

we also tried to other suggestion here:

livegrid.store.on( 'load', function( store, records, options ) {
var StoreIndex = livegrid.store.find('GROUPNAME','ID1');
alert(StoreIndex);
} );

ID1 does exist in the groupname column but when we alert it out it says undefined. which looks like it is running this code while the store is loaded and not when it has finished loading

thanks

j-joey
3 Aug 2010, 4:24 PM
when load event fired, store should be already loaded. as you know, fieldNames as case-sensitive. you may need to re-check your field names defined in store.

by the way the reason you get the "l.fireFn.apply is not a function" is you're assigning your callback function to "callback" instead of "fn". it should be



...
listeners: {
load: {
fn: function(){
alert("");
}
},
exception: function(misc) {
alert("Holy cow, we're getting an exception!");
}
},
...

cs01rsw
4 Aug 2010, 2:11 AM
ok thanks for the help, except there doesn't appear to be any data in the 'store' variable itself, however if we use the 'records' variable we can get the data