Skip to content
Tim Wisniewski edited this page Jan 22, 2016 · 6 revisions

Fields collections are basic Backbone Collections that contain information about each field/column in a dataset. They exist primarily to store readable field titles (ie. Violation Type instead of violation_type), which are used:

(a) in the table view for column headers, and screenshot of use in table view

(b) beneath each card when listing its current filters screenshot of use in card filters

When adding a provider, you can create a fields collection for it to implement a provider-specific way to fetch and parse field information.

Requirements

The class should extend BaseFields. At the time of this writing, BaseFields is a stub. But doing so will allow easier changes in the future.

The fields/items in the collection should have the following attributes:

  • data pointing to the field name in the dataset (ie. violation_type)
  • title pointing to the readable version of the field name (ie. Violation Type)
  • type with one of datatables' types (for table sorting)
  • defaultContent with a default value or an empty string ('')
  • Optional: description pointing to a description of the field

Beyond that, you can implement any other functionality Backbone Collections provide.

Note: The above API is a direct implementation of datatables columns, and should probably be abstracted. If you're interested in helping with this, post an issue about it!

Examples