How to call an event when the dojo dgrid has been rendered completely?

1.2k views Asked by At

We are using dojo without pagination and showing all records at once. We need to call a java script method when the entire grid has been rendered completely, so that the grid rows and cell can be used for DOM manipulation.

I am trying following code, but its not working.

aspect.after(grid,"dgrid-refresh-complete",function(){

});

grid.on("dgrid-refresh-complete", function(event){

}); 
1

There are 1 answers

5
Ken Franqueiro On BEST ANSWER

dgrid-refresh-complete is implemented specifically in OnDemandList and Pagination. If you're using the SingleQuery mixin instead (as in the tutorial for 0.3 or 0.4), it should be feasible to institute the same kind of event as follows:

var self = this;

// existing code from refresh...

// when(...) (via dojo/when) should only be necessary here for dgrid 0.3
var promise = when(this._trackError(/* existing code from refresh */));

promise.then(function () {
    on.emit(self.domNode, 'dgrid-refresh-complete', {
        bubbles: true,
        cancelable: false,
        grid: self
    });
});

return promise;

So, for example, in 0.3, SingleQuery's refresh method would look like this:

refresh: function () {
    var self = this;

    // First defer to List#refresh to clear the grid's
    // previous content
    this.inherited(arguments);

    if (!this.store) {
        return;
    }

    var promise = when(this._trackError(function () {
        var queryOptions = self.get('queryOptions'),
            results = self.store.query(
                self.query, queryOptions);

        return self.renderArray(
            results, null, queryOptions);
    }));

    promise.then(function () {
        on.emit(self.domNode, 'dgrid-refresh-complete', {
            bubbles: true,
            cancelable: false,
            grid: self
        });
    });

    return promise;
}