Miles
Miles

Reputation: 1635

Callback in renderer function for ExtJS Grid

I've got a renderer function that has to load some data from a store in order to return a value, but I haven't been able to figure out how to return what I want to the grid column.

{header: 'Manager First Name', 
renderer: function(value, meta, record){
    record.Managers().load({
        scope: this,
        callback: function(managers, operation, success){
            if(success && managers){
               managers[0].getPerson({
                    scope: this,
                    callback: function(person, operation){
                        if(person){
                            return person.get("firstName");
                        } else {
                            console.error('This manager doesn\'t have a person record.');
                            return '';
                        }
                    }
                });
            } else {
                console.error('No manager record for the shop '+record.getId());
            }
        }
    });
}}

I've tried placing return in front of the load and the getPerson functions to no avail. I thought of firing an event as well, but I'm not sure how that would look. Any ideas?

Upvotes: 1

Views: 3391

Answers (1)

sha
sha

Reputation: 17860

I would load your additional information prior to rendering the main grid. This way in the renderer() function you will use already loaded data.

Otherwise your renderer function will get called many times and you will have some big troubles loading your store asynchronously.

Upvotes: 2

Related Questions