Last active
August 29, 2015 14:00
-
-
Save paulwsmith/06b14fb813ef907a6de3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
columns = [ | |
{ | |
field: 'folder.name', | |
displayName: 'Folder', | |
width: 200, | |
enableCellEdit: false, | |
groupable: true, | |
visible: false, | |
sortFn: Model.makeSortFunction(currentFolders) | |
} | |
]; | |
Model.makeSortFunction = function(currentFolders) { | |
var currentSortOrder = []; | |
var max = -1; | |
angular.forEach(currentFolders, function(folder) { | |
if (folder.name !== 'Uncategorized') { | |
currentSortOrder[folder.name] = folder.order; | |
if (folder.order > max) { | |
max = folder.order; | |
} | |
} | |
}); | |
currentSortOrder.Uncategorized = max + 1; | |
return function(a, b) { | |
return currentSortOrder[a] - currentSortOrder[b]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment