browsable.collection.mixin
BrowsableCollectionMixin : d2/sdk/models/mixins/browsable.collection.mixin
BrowsableCollection mixin. Can be mixed with any Backbone.Collection
to make it paginated. Pagination happens on the client
side by slicing & maintaining the models in it. But when it syncs to the server, it always fetches the full list of available objects.
Besides pagination it also enables sorting & filtering.
Extends: Object
See: Browsable Support
Example (A typical usage infuses the mixin with a collection prototype)
define([
'nuc/lib/backbone',
'd2/sdk/models/mixins/browsable.collection.mixin'
], function(Backbone, BrowsableCollectionMixin){
'use strict';
var MyCollection = Backbone.Collection.extend({
constructor: function MyCollection(models, options) {
options = options || {};
MyCollection.__super__.constructor.call(this, models, options);
this.makeBrowsableCollection(options);
}
});
BrowsableCollectionMixin.mixin(MyCollection.ptototype);
return MyCollection;
});
- BrowsableCollectionMixin :
d2/sdk/models/mixins/browsable.collection.mixin
- instance
- static
- .mixin(prototype) ⇒
void
- .mixin(prototype) ⇒
browsableCollectionMixin.makeBrowsableCollection(options) ⇒ *
Does the necessary setup so that a Backbone.Collection
instance could become client-side paginated along with support for property based sorting & filtering.
Kind: instance method of BrowsableCollectionMixin
Returns: *
- the collection instance itself.
Param | Type | Description |
---|---|---|
options | Object | The options hash. |
[options.skip] | number | Number of elements to skip from original collection. Needs to be set only if the collection needs to start from a page other the page-1. |
options.top | number | Number of elements per page. |
[options.filter] | string | Any filter expression that the collection should begin with. Can be changed later with |
[options.orderBy] | string | Any sorting criteria that the collection should begin with. Can be changed later with |
BrowsableCollectionMixin.mixin(prototype) ⇒ void
Fuse the mixin methods to a prototype
Kind: static method of BrowsableCollectionMixin
Mixes: ClientSideBrowsableMixin
, BrowsableMixin
, module:DelayedCollectionDataMixin
Param | Type | Description |
---|---|---|
prototype | Object | The target prototype where the mixin methods will be fused. |