Skip to content

Instantly share code, notes, and snippets.

@paulwsmith
Last active August 29, 2015 14:00
Show Gist options
  • Save paulwsmith/06b14fb813ef907a6de3 to your computer and use it in GitHub Desktop.
Save paulwsmith/06b14fb813ef907a6de3 to your computer and use it in GitHub Desktop.
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