Skip to content

Commit

Permalink
added very basic total row and error display. resolves #9
Browse files Browse the repository at this point in the history
  • Loading branch information
wacki committed Nov 18, 2015
1 parent 05cc851 commit f553952
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
18 changes: 17 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ <h3>Generated Query (Read Only)</h3>

</form>

<span><span id="row-count">0</span> rows</span> <span id="error-message"></span>

<div id="myGrid" style="width:90%;height:490px;"></div>
<br />
<form id="download-form" method="post" action="http://test.lindas-data.ch/sparql" target="download-window">
Expand Down Expand Up @@ -112,7 +114,7 @@ <h3>Generated Query (Read Only)</h3>
enableCellNavigation: true,
enableColumnReorder: false,
syncColumnCellResize: true,
enableAddRow: true,
//enableAddRow: true,
asyncEditorLoading: true,
forceFitColumns: true,
topPanelHeight: 20,
Expand Down Expand Up @@ -190,11 +192,25 @@ <h3>Generated Query (Read Only)</h3>
grid.updateRowCount();
grid.render();

$("#row-count").html(args.count);

// hide loading indicator in case there are no results
if(args.count == 0)
loadingIndicator.fadeOut();
});

// probably not the best solution to displaying errors but...
loader.onErrorOccurred.subscribe(function (e, args) {
$("#error-message").html(args.msg);

var hideMsgTimer;
clearTimeout(hideMsgTimer);

hideMsgTimer = setTimeout(function () {
$("#error-message").html("");
}, 8000);
});

loader.onFilterValuesRetrieved.subscribe(function (e, args) {
console.log("Loaded filter values for " + args.column);
var selector = "#jq-dropdown-" + args.column + " .jq-dropdown-menu";
Expand Down
7 changes: 6 additions & 1 deletion js/data-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
var onColumnsChanged = new Slick.Event();
var onRowCountChanged = new Slick.Event();
var onFilterValuesRetrieved = new Slick.Event();
var onErrorOccurred = new Slick.Event();

function clearData() {
for (var key in data) {
Expand Down Expand Up @@ -230,6 +231,7 @@
onFilterValuesRetrieved.notify({ column: columnId, values: vals });
},
error: function () {
onErrorOccurred.notify({ msg: "Can't reach the server." });
console.log("error retrieving filter values");
}
});
Expand Down Expand Up @@ -272,6 +274,7 @@
complete();
},
error: function () {
onErrorOccurred.notify({ msg: "Can't reach the server." });
console.log("error retrieving count query results");
}
});
Expand Down Expand Up @@ -341,6 +344,7 @@
cache: true,
success: ajaxSuccess,
error: function () {
onErrorOccurred.notify({ msg: "Can't reach the server." });
console.log('error loading page ' + page.toString());
}
});
Expand Down Expand Up @@ -426,7 +430,8 @@
"onDataLoaded": onDataLoaded,
"onColumnsChanged": onColumnsChanged,
"onRowCountChanged": onRowCountChanged,
"onFilterValuesRetrieved": onFilterValuesRetrieved
"onFilterValuesRetrieved": onFilterValuesRetrieved,
"onErrorOccurred": onErrorOccurred
};
}

Expand Down

0 comments on commit f553952

Please sign in to comment.