ampersand-collection-sort-mixin
A mixin to provide simple ascending/descending sorting
Last updated 6 years ago by mikehedman .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ampersand-collection-sort-mixin 
SYNC missed versions from official npm registry.

ampersand-collection-rest-mixin

A mixin for extending ampersand-collection with the ability to sort by multiple properties, and ascending/descending. The sorting is performed when adding new models to the collection, or when the sort() method is called.

install

npm install ampersand-collection-sort-mixin

usage

The mixin uses two properties stored in session properties:

  • sortProps - Array of strings, or string. An array of the property names to sort the collection by. If just one, it can be just a string.
  • sortDescending - Boolean. Set to true to sort descending. Default is false (ascending)

example

var Collection = require('ampersand-collection');
var sortMixin = require('ampersand-collection-sort-mixin');


module.exports = Collection.extend(sortMixin, {
    session: {
        sortProps: ['lastname', 'firstname'],
        sortDescending: true
    },

});

credits

The main nugget of this code came from the base collection sort() method.

license

MIT

Current Tags

  • 0.0.4                                ...           latest (6 years ago)

2 Versions

  • 0.0.4                                ...           6 years ago
  • 0.0.3                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |