Data viewer with paging, sorting, and searching. Must use at least one extension to display items. Fuel UX bundles a list view extension and thumbnail view extension, but you can build your own. The following example uses the list and thumbnail extensions.
Because of its reliance upon a dataSource, you must initialize a repeater() via JavaScript:
Use the following markup to setup the repeater:
The repeater must be initialized via JavaScript, however it also accepts some optional data-attributes.
staticHeight on initialization.Pass options via JavaScript upon initialization.
| Name | type | default | description |
|---|---|---|---|
| dataSource | function | empty function | Use this function to provide paging information and data for the repeater. Call this function prior
to rendering the current view, passing a options object and callback
function. Run the callback function once you gather the appropriate information to complete
the rendering. Review more details on using dataSource below. |
| dataSourceOptions | object | null | Use this object to pass a parameter to a custom-defined dataSource function mentioned above. Then, use those values to customize the data that gets passed back into the repeater from your API. Suggested uses include sorting, filtering, and search values. This object is also valuable in custom renders when used as an object within the render methods's options parameter. Did you lose your custom dataSourceOptions when you changed the page within repeater? If you did, set preserveDataSourceOptions to true in order to keep them. |
| defaultView | string or number | -1 | Specifies the initial view the repeater will render (usually a string value equivalent
to the desired repeater view extension). If set to -1, the repeater will check the
.repeater-views button group for an .active class, using its input
value as the defaultView setting. |
| dropPagingCap | number | 10 | Specifies the number of items allowed within the .repeater-primaryPaging drop-down menu.
If the number of pages exceeds this amount, the code will use the .repeater-secondaryPaging input. |
| preserveDataSourceOptions | boolean | false | Sets whether defineddataSourceOptions get preserved or reset when the dataSource is called. For example, the dataSource function is called when navigating to another page. If you would like to keep previously defined settings such as search or filtering, then set to true. Setting to true is generally recommended when using dataSourceOptions to manipulate your data. |
| staticHeight | boolean or number | -1 |
|
| views | object | null |
Can be optionally used to configure multiple views, including those of the same view type (2 'list' views, 2
'thumbnail' views, etc) To utilize, first set the input values within .repeater-views to their
appropriate view names. For multiple views of the same type, use the . operator as a separator,
following the syntax [viewType].[viewName] (Ex: "list.view1") Then, within the views
option object, add these view names as attributes. Each attribute can be an object, with it's own view plugin / repeater
configuration. This configuration will then be honored by the repeater per view. Example:
{% highlight js %}
$('#myRepeater').repeater({
views: {
'list.view1': {
dropPagingCap: 20,
list_infiniteScroll: true,
list_selectable: 'multi'
},
'list.view2': {
dataSource: function(options, callback){ ... },
dropPagingCap: 30,
list_selectable: true
}
},
...
});
{% endhighlight %}
|
options object.
{% highlight js %}$('#myRepeater').repeater('clear');{% endhighlight %}
{% highlight js %}$('#myRepeater').repeater('clear', {preserve: true});{% endhighlight %}
| Attribute | type | description |
|---|---|---|
| clearInfinite | boolean | optional -- if true, preserve must also be set to true to have an effect. If infinite scrolling is enabled, setting to true will clear all non data-preserved elements. Defaults to false. |
| preserve | boolean | optional If true, only items that don't have the data-preserve attribute will be removed. Otherwise, all items will be removed. Defaults to false. |
options object.
{% highlight js %}$('#myRepeater').repeater('infiniteScrolling');{% endhighlight %}
{% highlight js %}$('#myRepeater').repeater('infinitescrolling', true, {hybrid: true, percentage: 60});{% endhighlight %}
| Argument | type | description |
|---|---|---|
| enable | boolean | If set to true, this function will enable infinite scrolling. Defaults to false. |
| options | object | Optional. Specifies the desired infinite scrolling settings. View the infinite scroll
documentation for more details on available features. Your code will ignore the dataSource option on this
object in favor of the dataSource on the repeater.
|
options object.
{% highlight js %}$('#myRepeater').repeater('render');{% endhighlight %}
{% highlight js %}$('#myRepeater').repeater('render', {'changeView': 'widescreen', 'preserve': true});{% endhighlight %}
| Attribute | type | description |
|---|---|---|
| changeView | string | If set to a string value, this attribute will change the current repeater view to be rendered. Defaults to
undefined. |
| clearInfinite | boolean | Passed to the clear method - see above for description. |
| pageIncrement | number or null | Use a number value to determine the amount by which the current page will increment or decrement. If
null the current page will reset to 0.
|
| preserve | boolean | Passed to the clear method - see above for description. |
Call the dataSource function prior to rendering data for the current view. Receives an
options object and callback function as arguments. The options object
provides context for which data should return. Please review the dataSourceOptions option if the dataSource needs to be manipulated (such as for a custom render, to search, to sort, or to filter). Use the callback to continue onward
with rendering.
The options object can vary in content depending on the view extension used. Many objects share
these common attributes in options object format:
| Attribute | type | description |
|---|---|---|
| filter | object | Provides context for the selected .repeater-filters drop-down item representing data
filtering. The object contains a text attribute for the displayed text and
a value attribute for the value of the selected item.
|
| pageIndex | number | Represents the current page of data. pageIndex is a zero-based index into an array and may need to be manipulated before requesting more data, if the server request is a one-based index. |
| pageSize | number | Provides context for the selected .repeater-itemization dropdown item value, representing the number of data items to be displayed |
| search | string | Provides context for the entered .repeater-search search box, representing the desired
user search value. Only present if the object includes a search value.
|
| view | string | Provides context for the selected .repeater-views button group item, representing
the current view. Used to determine view-specific return data.
|
The dataSource's callback function should run after gathering the desired data for rendering. This function requires the code to pass a
data object as an argument. Contents of the object will vary depending on the view
extension used. The attributes below include common expected attributes:
| Attribute | type | description |
|---|---|---|
| count | number | Provides the number of returned in the data to the repeater. Use this value as the text value for the
.repeater-count element.
|
| end | number | Provides the end index of current displayed data items to the repeater. Use this value as the text value for the
.repeater-end element.
|
| items | array | Array of objects representing the item data that will be displayed within the repeater. Use this value to populate the records in the .repeater-list element. The item objects can contain any number of attributes. Necessary attributes are defined by the repeater extension. |
| page | number | Sets the current repeater page. Also shown in the .repeater-primaryPaging or
.repeater-secondaryPaging element. page is 0-based.
|
| pages | number | Provides the number of available pages of data to the repeater. Use this value as the text value for the .repeater-pages
element. pages is 1-based.
|
| start | number | Provides the starting index of current displayed data items to the repeater. Use this value as the text value for the
.repeater-start element.
|
The default values are { count: 0, end: 0, items: [], page: 0, pages: 1, start: 0 }.
Use the dataSource method to keep your page safe from XSS.
data object argument passed to dataSource's callback function.cleanInput utility while gathering your data use the data is safely encoded.| Event Type | Description |
|---|---|
| disabled.fu.repeater | Fires whenever the repeater is disabled. |
| enabled.fu.repeater | Fires whenever the repeater is enabled. |
| filtered.fu.repeater | Fires whenever the repeater is filtered via the dropdown. Passes a filter value argument. |
| nextClicked.fu.repeater | Fires whenever the repeater next page button is clicked. |
| pageChanged.fu.repeater | Fires whenever the repeater page is changed via primary or secondary paging. NOTE: if the paged via
primary paging, an array is passed back as a parameter, containing the value and
data, respectively. If secondary paging causes the change, only a value is passed as
an argument.
|
| pageSizeChanged.fu.repeater | Fires whenever the repeater page size is changed. Passes a value argument. |
| previousClicked.fu.repeater | Fires whenever the repeater previous page button is clicked. |
| rendered.fu.repeater | Fires whenever the repeater has rendered data returned from the dataSource. Passes an object containing
data, options, and renderOptions. |
| resized.fu.repeater | Fires whenever the repeater is resized. |
| searchChanged.fu.repeater | Fires whenever the repeater search control is used. |
| viewChanged.fu.repeater | Fires whenever the repeater view is switched. Passes the currentView as an argument. |
All repeater events are fired on the .repeater classed element.
The repeater uses a view framework that allows for extensions to represent data in different ways. By default, Fuel UX comes with two repeater view extensions (list and thumbnail). Each extension provides additional options and requires different return data from the dataSource to render appropriately. For information on using extensions, visit the extensions page. You can also learn how to write your own repeater extension.
Data viewer with paging, sorting, and searching using list and thumbnail extensions. Can be extended further for various other renderings.
Live examples: