dojo dgrid渲染完成后如何调用事件?
How to call an event when the dojo dgrid has been rendered completely?
我们正在使用没有分页的 dojo 并一次显示所有记录。我们需要在整个网格渲染完成后调用一个java脚本方法,这样网格行和单元格就可以用来DOM操作了。
我正在尝试遵循代码,但它不起作用。
aspect.after(grid,"dgrid-refresh-complete",function(){
});
grid.on("dgrid-refresh-complete", function(event){
});
dgrid-refresh-complete
具体实现在OnDemandList
和Pagination
中。如果您使用的是 SingleQuery
mixin(如 0.3 or 0.4 的教程中所示),那么建立相同类型的事件应该是可行的,如下所示:
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;
因此,例如,在 0.3 中,SingleQuery 的 refresh
方法将如下所示:
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;
}
我们正在使用没有分页的 dojo 并一次显示所有记录。我们需要在整个网格渲染完成后调用一个java脚本方法,这样网格行和单元格就可以用来DOM操作了。
我正在尝试遵循代码,但它不起作用。
aspect.after(grid,"dgrid-refresh-complete",function(){
});
grid.on("dgrid-refresh-complete", function(event){
});
dgrid-refresh-complete
具体实现在OnDemandList
和Pagination
中。如果您使用的是 SingleQuery
mixin(如 0.3 or 0.4 的教程中所示),那么建立相同类型的事件应该是可行的,如下所示:
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;
因此,例如,在 0.3 中,SingleQuery 的 refresh
方法将如下所示:
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;
}