PDA

View Full Version : Suspending render event to load some data



karantir
19 Aug 2009, 9:15 AM
Hi, all!
I'm trying to cancel render event to load some necessary data first, and then resume compnent rendering with respect to this data. I've implemented it like this


onDocumentBeforeRender: function(){
if(!this.statesLoaded){
Ext.Ajax.request({
url: '/documents/states/list/',
params: {
type: this.docType
},
callback: function(options, success, response){
if(success){
this.statesLoaded = true
this.render()
}
},
scope: this
})
return false
}
}

firebug says: "ct is null [Break on this error] this.el = ct.createChild({" and refers me to line 15916 of ext-all-debug.js
I have no idea what's wrong. Help please ))

avsomeren
19 Aug 2009, 12:30 PM
What exactly are you trying to achieve here...
Your ajax call will never cancel any event whatsoever imho.

If this is your prefereed way to go, might consider checking stopEvent();

Animal
19 Aug 2009, 12:52 PM
Can't do it.

What application problem are you trying to solve?

Jack9
19 Aug 2009, 3:05 PM
Why not include the rendering of the "problem component" in the

load:function(){
//problemComponent.render('myDestination');
// or
//componentY.add(problemComponent);
}

of the datastore (or whatever is loading)?

karantir
20 Aug 2009, 9:08 AM
I'm trying to implement a kind of documents editor and i need to know document state before rendering, because it significantly affects total layout. And i can't fetch document state before constructor call due to specific application architecture.

It seems i've solved the problem by passing 'container' reference in the component constructor, so i can call render method in ajax callback with required 'ct' parameter like this:



onDocumentBeforeRender: function(){
if(!this.statesLoaded){
Ext.Ajax.request({
url: '/documents/states/list/',
params: {
type: this.docType
},
callback: function(options, success, response){
if(success){
// final layout configuration machinery here
this.statesLoaded = true
this.render(this.container)
}
},
scope: this
})
return false
}
}


Wonder why i should do that, it could be perfectly implemented in Ext.Component.render method, so the user can generically resume render event (like in my former post). It quite helpful sometimes.

Thank you, guys, for participation.
Good luck ))