1
我在Dojo中遇到了一些困難。我正在嘗試構建一個包含dgrid的小部件。何時調用DGrid.startup() - 調用過早導致渲染效果不佳
的dgrid呈現這樣的:
調整瀏覽器窗口後,一切都很好,它顯示是這樣的:
我認爲這個問題我運行進入與調用grid.startup()
函數太早有關。當我將通話延遲10秒鐘(請參閱註釋部分代碼)時,所有內容均按預期工作。
這是我的代碼:
define([
// ...
],
function(
// ...
) {
return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin] ,{
templateString: template,
startup: function(){
this.inherited(arguments);
var store = new Memory({data: this.someArray});
var grid = new (declare([OnDemandGrid, DijitRegistry]))({
store: store,
columns: {
name: "Name column"
}
}, this.gridDiv);
// If I wrap startup in this - everything is fine.
// window.setInterval(function(){
grid.startup();
// }, 1000*10);
}
});
}
);
這是我使用的模板:
<div style="height:100%">
<table border="1">
<tr>
<td>
<button data-dojo-attach-point="addBtn" data-dojo-type="dijit/form/Button">Add item</button>
<div data-dojo-attach-point="gridDiv"></div>
</td>
<td>
Insert Summary here.
</td>
</tr>
</table>
</div>
問:這到底是怎麼回事?我應該在哪裏給dgrid打電話啓動?