Results 1 to 5 of 5

Thread: Suspending render event to load some data

  1. #1

    Default Suspending render event to load some data

    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
    Code:
    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 ))
    Last edited by sven; 19 Aug 2009 at 9:18 AM. Reason: moved from gxt forums to extjs forums

  2. #2
    Sencha User
    Join Date
    Jul 2009
    Posts
    32

    Default

    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();

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Can't do it.

    What application problem are you trying to solve?

  4. #4
    Touch Premium Member
    Join Date
    Sep 2008
    Location
    Orange County, CA, USA
    Posts
    186

    Default Reverse it

    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)?

  5. #5

    Default

    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:

    Code:
    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 ))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •