我有以下的mixin在JS /部件/ LoadAllStoreMixin.js聲明:定製_StoreMixin爲dGrid沒有做它應該做的
define([ 'dojo/_base/declare', 'dgrid/_StoreMixin' ], function(declare,
_StoreMixin) {
return declare(_StoreMixin, {
// summary:
// dgrid mixin which implements the refresh method to
// always perform a single query with no start or count
// specified, to retrieve all relevant results at once.
// Appropriate for grids using memory stores with small
// result set sizes.
refresh : function() {
var self = this;
// First defer to List#refresh to clear the grid's
// previous content
this.inherited(arguments);
if (!this._renderedCollection) {
return;
}
return this._trackError(function() {
var queryResults = self._renderedCollection.fetch();
queryResults.totalLength.then(function(total) {
// Record total so it can be retrieved later via
// get('total')
self._total = total;
});
return self.renderQueryResults(queryResults);
});
},
renderArray : function() {
var rows = this.inherited(arguments);
// Clear _lastCollection which is ordinarily only used for
// store-less grids
this._lastCollection = null;
return rows;
}
});
});
這是寫在http://dgrid.io/tutorials/0.4/single_query/允許的OnDemandList相同的部件加載一切,而不是隻有minRowsPerPage
記錄。它被稱爲是這樣的:
var gridDataString = dom.byId("connectedEnvironmentsAndLevelsGridData").innerHTML;
eval("var connectedEnvironmentsAndLevelsGridJsonData=" + gridDataString);
var connectedEnvironmentsAndLevelsStore = new Memory(
{ data: connectedEnvironmentsAndLevelsGridJsonData }
);
var SelectionGrid = declare([ Grid, LoadAllStoreMixin, Selection, Keyboard, DijitRegistry]);
connectedEnvironmentsAndLevelsGrid = new SelectionGrid({
store : connectedEnvironmentsAndLevelsStore,
selectionMode : "toggle",
columns : connectedEnvironmentsAndLevelsGridHeader,
allowSelectAll : true,
allowSelect: function(row) {
// disable the grid's rows basing on the phase compatibility
// if true, the row selection is enabled, otherwise disabled
return checkPhaseCompatibility(row);
}
}, "connectedEnvironmentsAndLevelsGrid");
// Grid is an OnDemandGrid, not a normal grid.
它被正確加載(所以有與define([], function(){});
樣板沒有問題),但由於某些原因,它在第一if
的refresh()
返回,所以它不會做什麼它應該。我不知道爲什麼這會失敗。我是否需要編寫更多的代碼,而不僅僅是refresh()
和renderArray()
函數?
我實際上不確定我使用的是什麼版本的dgrid。如果它還沒有收集,它可能早於0.4。這是Dojo 1.8的版本。我們無法輕易改變這個版本,所以我可能需要一個來自Dojo 1.8附帶的dgrid版本的例子。 – Nzall
我檢查了changeLog。我們使用的是dGrid 0.3.14。 – Nzall
@Nzall用更多信息更新了帖子。 –