This interface is implemented by the caplin.grid.DataProviderRowModel so that caplin.grid.GridDataProvider instances are able to communicate data changes as they occur. caplin.grid.GridDataProvider instances are given a reference to any listeners that may be interested in these events via the caplin.grid.GridDataProvider#addDataProviderListener method.
Attributes | Name and Description |
---|---|
|
caplin.grid.GridDataProviderListener()
|
Attributes | Name and Description |
---|---|
|
void
onDataReceived()
This callback is invoked when requested data is first received - before any calls to #onRecordAdded, #onRecordMoved or #onSizeChanged or #onStructureChangeComplete are called. |
|
void
onDataRequested()
This callback is invoked when a request for a data has been initiated (but not a window-adjusting request) |
|
void
onDataUnavailable(String sReason)
This callback is invoked when a request for data fails. |
|
void
onRecordAdded(String sRecordId, int nIndex, Map mRecord, String sAlternateId)
Callback that occurs when one or more of the visible records are replaced by new records and need to be completely redrawn. |
|
void
onRecordContentsChanged(String sRecordId, Map mRecordUpdates)
Callback that occurs when there are updates to one or more of the visible records. |
|
void
onRecordMoved(String sRecordId, int nIndex)
Callback that occurs when a visible record is moved to a new location, and remains visible within the current page. |
|
void
onRecordRemoved(String sRecordId)
Callback that occurs when a visible record is removed/deleted. |
|
void
onSizeChanged(int nNewSize, int nOldSize)
Callback that occurs when the number of underlying records available changes. |
|
void
onStartIndexChanged(int nNewStartIndex)
Callback that occurs when, for some reason, the data provider wishes to change the start index that the view is currently looking at. |
|
void
onStructureChangeComplete()
Callback that occurs after a number of invocations to #onRecordAdded, #onRecordMoved or #onSizeChanged have been made, informing the caplin.grid.DataProviderRowModel, and underlying caplin.grid.GridView that all updates can now be rendered. |
►
caplin.grid.GridDataProviderListener()
►
void
onDataReceived()
This callback is invoked when requested data is first received - before any calls to #onRecordAdded, #onRecordMoved or #onSizeChanged or #onStructureChangeComplete are called.
►
void
onDataRequested()
This callback is invoked when a request for a data has been initiated (but not a window-adjusting request)
►
void
onRecordAdded(String sRecordId, int nIndex, Map mRecord, String sAlternateId)
Callback that occurs when one or more of the visible records are replaced by new records and need to be completely redrawn.
This may happen because the user has scrolled the grid display causing different records to be displayed at the old indices, or when the underlying data changes, such that records are inserted, deleted or removed. When caplin.grid.GridDataProvider#PAGING is in use then only records within the range defined by caplin.grid.GridDataProvider#setRowRange are reported on.
String | sRecordId | the unique identifier that the caplin.grid.GridDataProvider is using to track the records that it reports on. |
int | nIndex | The row index at which the record exists. |
Map | mRecord | The map of name value/pairs that contain the record data. |
String | sAlternateId | Alternate Identifier (Deprecated, as there is no known need for an alternate id) |
►
void
onRecordContentsChanged(String sRecordId, Map mRecordUpdates)
Callback that occurs when there are updates to one or more of the visible records.
String | sRecordId | the unique identifier that the caplin.grid.GridDataProvider is using to track the records that it reports on. |
Map | mRecordUpdates | a map containing the updated field data. |
►
void
onRecordMoved(String sRecordId, int nIndex)
Callback that occurs when a visible record is moved to a new location, and remains visible within the current page.
If a record moves out of view, then the data provider does not need to perform any action, since that record will either be overwritten by some other #onRecordAdded or #onRecordMoved invocation, or will be effectively removed by an #onSizeChanged invocation with a smaller size that means that some of the previous row indices no longer exist at all.
String | sRecordId | the unique identifier that the caplin.grid.GridDataProvider is using to track the records that it reports on. |
int | nIndex | The row index at which the record will now exist. |
►
void
onRecordRemoved(String sRecordId)
Callback that occurs when a visible record is removed/deleted.
If a record is deleted from the source of the data provider's data then calling this should clean up any reference to the now defunct row.
String | sRecordId | the unique identifier that the caplin.grid.GridDataProvider is using to track the records that it reports on. |
►
void
onSizeChanged(int nNewSize, int nOldSize)
Callback that occurs when the number of underlying records available changes.
This has no relation to the number of records that are being displayed, and is only a measure of the available records.
int | nNewSize | the total number of available records. |
int | nOldSize | the previous total number of available records. |
►
void
onStartIndexChanged(int nNewStartIndex)
Callback that occurs when, for some reason, the data provider wishes to change the start index that the view is currently looking at.
This event allows the data provider to adjust the start index that the view has previously set using caplin.grid.GridDataProvider#setRowRange. There are a number of reasons a data provider might wish to do this:
All of these scrolling strategies could be, and probably should be, implemented within the caplin.grid.DataProviderRowModel, but for the purposes of efficiency it is also useful to allow them to be implemented directly within data provider, since this allows the number of round trips for data to be reduced.
int | nNewStartIndex |
►
void
onStructureChangeComplete()
Callback that occurs after a number of invocations to #onRecordAdded, #onRecordMoved or #onSizeChanged have been made, informing the caplin.grid.DataProviderRowModel, and underlying caplin.grid.GridView that all updates can now be rendered.
Allowing updates to be batched like this allows the caplin.grid.GridView class to perform more
efficiently since it is able to use a single call to innerHTML
to re-render a changed grid, rather than
making lots of expensive, individual DOM calls.