Home Reference Source
import {DataBoundScrollView} from 'arva-js/components/DataBoundScrollView.js'
public class | source

DataBoundScrollView

Extends:

famous-flex/FlexScrollView.js~FlexScrollViewReflowingScrollView → DataBoundScrollView

A FlexScrollView with enhanced functionality for maintaining a two-way connection with a PrioritisedArray.

Constructor Summary

Public Constructor
public

constructor(options: Object)

Be sure to specifiy either a getSize function in the class of the itemTemplate, or to specify the size in the layoutOptions.

Method Summary

Public Methods
public

Clears the dataSource by removing all entries

public

Gets the currently set dataStore.

public

Returns the currently active group elements, or an empty object of none are present.

public

Determines whether the last element showing is the actual last element

public

reloadFilter(newFilter: Function, reRender: Boolean): Promise

Reloads the dataFilter option of the DataBoundScrollView, and verifies whether the items in the dataStore are allowed by the new filter.

public

setDataStore(dataStore: *)

Sets the datastore to use.

public

setGroupTemplate(templateFunction: *, reRender: *)

Sets a group template function, optionally re-renders all the dataSource' renderables.

public

setItemTemplate(templateFunction: *)

Set a template function, optionally re-renders all the dataSource' renderables

Public Constructors

public constructor(options: Object) source

Be sure to specifiy either a getSize function in the class of the itemTemplate, or to specify the size in the layoutOptions.

Override:

ReflowingScrollView#constructor

Params:

NameTypeAttributeDescription
options Object

The options passed inherit from previous classes. Avoid using the dataSource option since the DataBoundScrollView creates its own dataSource from options.dataStore.

options.dataStore PrioriisedArray
  • optional

The data that should be read to create entries.

options.itemTemplate Function
  • optional

A function that returns a renderable representing each data item.

options.placeholderTemplate Function
  • optional

A function that returns a renderable to display when there are no items present.

options.headerTemplate Function
  • optional

A function that returns a renderable to display as a header.

options.orderBy Function
  • optional

An ordering function that takes two data models (model1, model2). If it returns true, then model1 should go before model2.

options.groupBy Function
  • optional

A function that takes a model and returns a value to group by. If set, then the groupTemplate option also needs to be set.

options.groupTemplate Function
  • optional

A function that takes as a single argument the groupBy value and returns a renderable to insert before a group belonging to that value.

options.stickHeaders Boolean
  • optional

If set to true, then the group headers will stick to the top when scrolling. Beware that this is slightly buggy as of now and might require some fine tuning to provide a better UX.

options.customInsertSpec Function
  • optional

A function that takes as a single argument a model and returns a spec that is used when inserting a new item.

options.chatScrolling Boolean
  • optional

If set to true, the scroll will remain at the bottom if at bottom already when new messages are added.

If this function returns true, then model1 will be placed before model2.

Public Methods

public clearDataSource() source

Clears the dataSource by removing all entries

public getDataStore(): * source

Gets the currently set dataStore.

Return:

*

public getGroups(): Object source

Returns the currently active group elements, or an empty object of none are present.

Return:

Object

public isAtBottom(): boolean source

Determines whether the last element showing is the actual last element

Return:

boolean

True if the last element showing is the actual last element

public reloadFilter(newFilter: Function, reRender: Boolean): Promise source

Reloads the dataFilter option of the DataBoundScrollView, and verifies whether the items in the dataStore are allowed by the new filter. It removes any currently visible items that aren't allowed anymore, and adds any non-visible ones that are allowed now.

Params:

NameTypeAttributeDescription
newFilter Function

New filter function to verify item visibility with.

reRender Boolean

Boolean to rerender all childs that pass the filter function. Usefull when setting a new itemTemplate alongside reloading the filter

Return:

Promise

Resolves when filter has been applied

public setDataStore(dataStore: *) source

Sets the datastore to use. This will repopulate the view and remove any (if present) old items.

Params:

NameTypeAttributeDescription
dataStore *

public setGroupTemplate(templateFunction: *, reRender: *) source

Sets a group template function, optionally re-renders all the dataSource' renderables.

Params:

NameTypeAttributeDescription
templateFunction *
reRender *

public setItemTemplate(templateFunction: *) source

Set a template function, optionally re-renders all the dataSource' renderables

Params:

NameTypeAttributeDescription
templateFunction *