Skip to content

Commit 921556f

Browse files
authored
Update OnDemandList to emit dgrid-error if scrolling encounters and error. (dojo#1481)
1 parent 0d9ef86 commit 921556f

File tree

2 files changed

+54
-52
lines changed

2 files changed

+54
-52
lines changed

OnDemandList.js

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -735,65 +735,67 @@ define([
735735
(function (loadingNode, below, keepScrollTo) {
736736
/* jshint maxlen: 122 */
737737
var rangeResults = preload.query(options);
738-
lastRows = grid.renderQueryResults(rangeResults, loadingNode, options).then(function (rows) {
739-
var gridRows = grid._rows;
740-
if (gridRows && !('queryLevel' in options) && rows.length) {
741-
// Update relevant observed range for top-level items
742-
if (below) {
743-
if (gridRows.max <= gridRows.min) {
744-
// All rows were removed; update start of rendered range as well
738+
lastRows = grid._trackError(function () {
739+
return grid.renderQueryResults(rangeResults, loadingNode, options).then(function (rows) {
740+
var gridRows = grid._rows;
741+
if (gridRows && !('queryLevel' in options) && rows.length) {
742+
// Update relevant observed range for top-level items
743+
if (below) {
744+
if (gridRows.max <= gridRows.min) {
745+
// All rows were removed; update start of rendered range as well
746+
gridRows.min = rows[0].rowIndex;
747+
}
748+
gridRows.max = rows[rows.length - 1].rowIndex;
749+
}
750+
else {
751+
if (gridRows.max <= gridRows.min) {
752+
// All rows were removed; update end of rendered range as well
753+
gridRows.max = rows[rows.length - 1].rowIndex;
754+
}
745755
gridRows.min = rows[0].rowIndex;
746756
}
747-
gridRows.max = rows[rows.length - 1].rowIndex;
748757
}
749-
else {
750-
if (gridRows.max <= gridRows.min) {
751-
// All rows were removed; update end of rendered range as well
752-
gridRows.max = rows[rows.length - 1].rowIndex;
753-
}
754-
gridRows.min = rows[0].rowIndex;
758+
759+
// can remove the loading node now
760+
beforeNode = loadingNode.nextSibling;
761+
domConstruct.destroy(loadingNode);
762+
// beforeNode may have been removed if the query results loading node was removed
763+
// as a distant node before rendering
764+
if (keepScrollTo && beforeNode && beforeNode.offsetWidth) {
765+
// if the preload area above the nodes is approximated based on average
766+
// row height, we may need to adjust the scroll once they are filled in
767+
// so we don't "jump" in the scrolling position
768+
grid.scrollTo({
769+
y: grid.bodyNode.scrollTop + beforeNode.offsetTop - keepScrollTo
770+
});
755771
}
756-
}
757772

758-
// can remove the loading node now
759-
beforeNode = loadingNode.nextSibling;
760-
domConstruct.destroy(loadingNode);
761-
// beforeNode may have been removed if the query results loading node was removed
762-
// as a distant node before rendering
763-
if (keepScrollTo && beforeNode && beforeNode.offsetWidth) {
764-
// if the preload area above the nodes is approximated based on average
765-
// row height, we may need to adjust the scroll once they are filled in
766-
// so we don't "jump" in the scrolling position
767-
grid.scrollTo({
768-
y: grid.bodyNode.scrollTop + beforeNode.offsetTop - keepScrollTo
773+
rangeResults.totalLength.then(function (total) {
774+
if (!('queryLevel' in options)) {
775+
grid._total = total;
776+
if (grid._rows && grid._rows.max >= grid._total - 1) {
777+
grid._rows.max = Infinity;
778+
}
779+
}
780+
if (below) {
781+
// if it is below, we will use the total from the collection to update
782+
// the count of the last preload in case the total changes as
783+
// later pages are retrieved
784+
785+
// recalculate the count
786+
below.count = total - below.node.rowIndex;
787+
// readjust the height
788+
grid._adjustPreloadHeight(below);
789+
}
769790
});
770-
}
771791

772-
rangeResults.totalLength.then(function (total) {
773-
if (!('queryLevel' in options)) {
774-
grid._total = total;
775-
if (grid._rows && grid._rows.max >= grid._total - 1) {
776-
grid._rows.max = Infinity;
777-
}
778-
}
779-
if (below) {
780-
// if it is below, we will use the total from the collection to update
781-
// the count of the last preload in case the total changes as
782-
// later pages are retrieved
783-
784-
// recalculate the count
785-
below.count = total - below.node.rowIndex;
786-
// readjust the height
787-
grid._adjustPreloadHeight(below);
788-
}
792+
// make sure we have covered the visible area
793+
grid._processScroll();
794+
return rows;
795+
}, function (e) {
796+
domConstruct.destroy(loadingNode);
797+
throw e;
789798
});
790-
791-
// make sure we have covered the visible area
792-
grid._processScroll();
793-
return rows;
794-
}, function (e) {
795-
domConstruct.destroy(loadingNode);
796-
throw e;
797799
});
798800
})(loadingNode, bottomPreload, keepScrollTo);
799801
});

test/widgets/SelectServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define([
88
'../data/restMock',
99
'dojo/text!./SelectServer.html'
1010
], function (Deferred, ioQuery, on, requestRegistry, _WidgetBase, _TemplatedMixin, restMock, template) {
11-
var NODEJS_TARGET_URL = window.location.origin + ':8040/data/rest';
11+
var NODEJS_TARGET_URL = 'http://' + window.location.hostname + ':8040/data/rest';
1212
var PHP_TARGET_URL = '../data/rest.php';
1313
var TIMEOUT = 1500; // milliseconds; timeout for server up status check
1414

0 commit comments

Comments
 (0)