Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix Initial Sort Direction (issue #576) #628

Merged
merged 1 commit into from

6 participants

@psgibbs

Fixes Issue #576 – the current build doesn't work when trying to specify a multi-column sort in the gridOptions.sortInfo.

@aleksashin

Hey, we faced the same issue. Can we get it merged into master asap?

@nvdv

+1

@psgibbs

@roblarsen let me know if you need anything more from me to help get this merged

@roblarsen
Owner

Thanks

@roblarsen roblarsen merged commit 0222f30 into from
@roblarsen
Owner

Sorry. I'm juggling trying to find time to work this in general and then struggling to work on 3.0 and still manage getting a stable 2.0.8 finished for people who've been working with that version.

@aleksashin

Thank you for your time!

@aleksashin

@roblarsen Can we please update build files to include these changes?

@jonricaurte Can we please update build files?

@aleksashin

@jonricaurte I mean build/ng-grid.debug.js and build/ng-grid.min.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 14, 2013
  1. @psgibbs

    fix initial sortInfo, allows users to specify multiple columns for so…

    psgibbs authored
    …rting when initializing ng-grid
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 8 deletions.
  1. +13 −8 src/classes/grid.js
View
21 src/classes/grid.js
@@ -626,7 +626,6 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
self.lastSortedColumns.push(c);
};
if (isArr) {
- self.clearSortingData();
angular.forEach(col, function (c, i) {
c.sortPriority = i + 1;
push(c);
@@ -636,10 +635,11 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
col.sortPriority = undefined;
push(col);
}
+
+ self.sortActual();
+ self.searchProvider.evalFilter();
+ $scope.$emit('ngGridEventSorted', self.config.sortInfo);
}
- self.sortActual();
- self.searchProvider.evalFilter();
- $scope.$emit('ngGridEventSorted', self.config.sortInfo);
};
self.sortColumnsInit = function() {
if (self.config.sortInfo.columns) {
@@ -647,16 +647,21 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
} else {
self.config.sortInfo.columns = [];
}
+
+ var cols = [];
angular.forEach($scope.columns, function(c) {
var i = self.config.sortInfo.fields.indexOf(c.field);
if (i !== -1) {
c.sortDirection = self.config.sortInfo.directions[i] || 'asc';
- self.config.sortInfo.columns[i] = c;
+ cols[i] = c;
}
});
- angular.forEach(self.config.sortInfo.columns, function(c){
- self.sortData(c);
- });
+
+ if(cols.length === 1){
+ self.sortData(cols[0]);
+ }else{
+ self.sortData(cols);
+ }
};
self.sortActual = function() {
if (!self.config.useExternalSorting) {
Something went wrong with that request. Please try again.