Skip to content

Commit

Permalink
QueryFiddle: reset sorting when executing query. fixes #33
Browse files Browse the repository at this point in the history
  • Loading branch information
amirnissim committed Jan 23, 2014
1 parent c05cf29 commit 82fe6f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rd_ui/app/scripts/query_fiddle/renderers.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ renderers.directive('gridRenderer', function () {
isPaginationEnabled: true,
itemsByPage: $scope.itemsPerPage || 15,
maxSize: 8
}
};

$scope.$watch('queryResult && queryResult.getData()', function (data) {
if (!data) {
Expand Down
12 changes: 10 additions & 2 deletions rd_ui/app/scripts/smart-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@

//if item are added or removed into the data model from outside the grid
scope.$watch('dataCollection', function (oldValue, newValue) {
if (oldValue !== newValue) {
ctrl.sortBy();//it will trigger the refresh... some hack ?
// evme:
// reset sorting when data updates (executing query again)
if (newValue) {
ctrl.resetSort();
}
});

Expand Down Expand Up @@ -496,6 +498,12 @@
return scope.isPaginationEnabled ? arrayUtility.fromTo(output, (scope.currentPage - 1) * scope.itemsByPage, scope.itemsByPage) : output;
};

this.resetSort = function() {
lastColumnSort = null;
predicate = {};
this.sortBy();
};

/*////////////
Column API
///////////*/
Expand Down

0 comments on commit 82fe6f6

Please sign in to comment.