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.
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
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
binds data from dataset to data in control
- Parameters:
- {Banana.Controls.DataControl} c
binds data from dataset to datasource in control
- Parameters:
- {Banana.Controls.DataControl} c
Persist the data from the controls to the dataset. This function should be used after a successful save to reset the dataChanged flags.
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
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
Get the dataset with changed values from input fields
- Returns:
- {mixed} The dataset
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}
sets data on control from dataset data
- Parameters:
- {Banana.Controls.DataControl} c
- {mixed} d
sets datasource data on control from dataset data
- Parameters:
- {Banana.Controls.DataControl} c
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}
- Parameters:
- {String} id
- sets the datakey which is used to maintain key value pointer references
unbinds control from this dataset
- Parameters:
- {Banana.Controls.DataControl} c