Skip to content

Commit

Permalink
added request error callback support
Browse files Browse the repository at this point in the history
  • Loading branch information
gnibeda committed Nov 12, 2020
1 parent b8f94d5 commit 871d3f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ var setup = { // Object that contain settings. Properties in brackets can be mis
// if rowClick callback returns boolean false, DrillDown won't be performed.
, rowClick: function (row, rowData) { console.log(row, rowData); }
, contentRendered: function () {}
// triggers when request status is not 200
, requestError: function (message, xhr) {}
, cellSelected: function ({ x: Number, y: Number, leftHeaderColumnsNumber: Number, topHeaderRowsNumber: Number }) {
return false; // return false to block default click action
}
Expand Down
7 changes: 6 additions & 1 deletion source/js/DataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ DataSource.prototype._post = function (url, data, callback) {
}
})());
} else if (xhr.readyState === 4 && xhr.status !== 200) {
handler = self.LPT.CONFIG.triggers["requestError"];
if (typeof handler === "function") {
handler.call(this, xhr.responseText || pivotLocale.get(3) + "<br/>" +
xhr.status + ": " + xhr.statusText, xhr);
}
callback({
error: xhr.responseText || pivotLocale.get(3) + "<br/>" +
xhr.status + ": " + xhr.statusText
Expand Down Expand Up @@ -282,4 +287,4 @@ DataSource.prototype.getCurrentData = function (callback) {
requestData();
}

};
};

0 comments on commit 871d3f9

Please sign in to comment.