-
Notifications
You must be signed in to change notification settings - Fork 35
Adding a provider
Mark Headd edited this page Jan 28, 2016
·
7 revisions
-
initialize
should call itsBaseProvider
's method viaBaseProvider.prototype.initialize.apply(this, arguments)
- To use a custom [fields collection](fields collections), create a class that extends
basefields.js
and set thefieldsCollection
property to it in the provider -
url
should handle URL construction based on the state of the collection (current filters, sorting, etc.) -
exportUrl
should return the downloadable (CSV) version of theurl
-
getRecordCount
should return adeferredpromise that passes the total number of records that exist when resolved -
getFields
should return a promise that passes a collection (of instanceBaseFields
) when resolved
getFields
should leverage this.fieldsCache
, a hash of dataset
s and fields collections, to share fields collections between provider collections of the same dataset. To access the relevant fields collection, use this.fieldsCache[this.config.dataset]
.
Beyond that, you can use any other configuration options of Backbone Collections such as parse
.
- Add your provider to
providers.js
- Specify its use using the
provider
option in a card's config object