Index

Classes

Class

Methods

Class Banana.Data.DataSet


Extends Banana.Control.

Methods borrowed from class Banana.Control:
addControl, applyToChildren, createComponents, findControl, generateUniqueId, getClientId, getControls, getDomEventTypes, getFirstUiControl, getHtml, getId, getPage, getParent, getProxy, hasBind, invalidateDisplay, onPreInvalidateContents, onWindowResize, remove, render, setClientId, setId, setPage, setParent, triggerEvent, unbind, unload, updateDisplay

Defined in: DataSet.js.

Class Detail
Banana.Data.DataSet()

Datasets are local storages to maintain data in one central place and provide all or parts of the data to controls. All DataControls within banana have bindDataSet and bindDataSourceSet methods available to bind on a specific dataset.

it looks like this

Control.bindDataSet("datasetName","optionalProperty");

the optionalProperty is used when you supply a complex object as data in your dataset. For example

var data = {"value1":"foo","value2":"foo2"} Control.bindDataSet("datasetName",value1);

Data can be of any type. Strings, Arrays or Deep nested arrays/objects.

Changing data in controls propagates back to the dataset to maintain consistent data. There are 3 ways of getting data from the dataset 1. getData() retreives the original data. changes in controls will not affect this data, unless commitControlData is used 2. getControlData() retreives only data which have registered controls on it 3. getChangedDataSet() retreives all data with the latest by controls modified data

When new data is inserted in the dataset all controls are getting updated with new data. Sometimes you are using complex data like var data = {"value1":{'id':12,'name':'foo'}} When you update the dataset with new data like var data = {"value1":{'id':12,'name':'foo foo foo foo foo foo'}} You want to keep the references pointing to the same origin. Dataset handles this for you by suppling a key with setDataKey() on the dataset

If new data is inserted only data which is changed will affect controls. This increases performance.

use dataset.clientUpdate to make data visible into the controls

Method Detail
bind(name, func)

we overwrite the bind function to detect if a user listens to controldatachaged events if so, we register on every control attached to this dataset a listener.

Parameters:
name
func
bindControlToData(c)

binds data from dataset to data in control

Parameters:
{Banana.Controls.DataControl} c
bindControlToDataSource(c)

binds data from dataset to datasource in control

Parameters:
{Banana.Controls.DataControl} c
clear()

Clears the dataset by removing internal data and unregisters all controls

clearControlData()

clears the data in all controls

clientUpdate()

updates all registered controls with the current dataset data

commitControlData()

Persist the data from the controls to the dataset. This function should be used after a successful save to reset the dataChanged flags.

controlChangedHandler(Event)

handler for change events. checks current changed control and store changed status in an array this is needed to track changes of controls. only when all checked controls are equal to original data we fire a restoreevent. unaffected controls are playing no role in the descision of firing the change or restore event

TODO needs to be improved. Could slow down things a bit

Parameters:
Event
e
ensureObjectFromPath(obj, path, props, refpath, refObj)

ensures an object contains properties acording to dot limited path additionaly possible to insert data at last property

Parameters:
{object} obj
{string} path
i.e test.sub.subsu
{object} props
to insert at last property
{string} refpath
used by function
{object} refObj
used by function
{mixed} getChangedDataSet()

Get the dataset with changed values from input fields

Returns:
{mixed} The dataset
{object} getControlData(when)

Retreives the data from all registered data controls. Besides the data we also have the original data and isDataChanged boolean

Parameters:
{flattened} when
true we just return a key value object
Returns:
{object}
{mixed} getData()

returns data in dataset always returns most up to date data

Returns:
{mixed} data
{mixed} getDataByPath(path)
Parameters:
{String} path
Returns:
{mixed}
{boolean} getIsChanged()
Returns:
{boolean} true when data is changed.
resetControls()

resets control to original data

setControlData(c, d)

sets data on control from dataset data

Parameters:
{Banana.Controls.DataControl} c
{mixed} d
setControlDataSource(c)

sets datasource data on control from dataset data

Parameters:
{Banana.Controls.DataControl} c
{this} setData(d, ignoreEqualCheck)

sets data in dataset We check if previous data is changed compared to new data. if so we copy all new properties to the old data, to make sure our object references stay intact. this is specialy usefull to prevent changes between items

so that only changed controls are getting updated

Parameters:
{mixed} d
data
{boolean} ignoreEqualCheck
when true we dont check if new data is equal to old.
Returns:
{this}
setDataByPath(data, path)

sets data by path

Parameters:
{mixed} data
{String} path
setDataKey(id)
Parameters:
{String} id
sets the datakey which is used to maintain key value pointer references
unBindControl(c)

unbinds controls from this dataset

Parameters:
{Banana.Controls.DataControl} c
unBindDataSourceControl(c)

unbinds control from this dataset

Parameters:
{Banana.Controls.DataControl} c

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 05 2012 22:02:03 GMT+0100 (CET)