DataProvider

The DataProvider Class provides properties, methods, and events to interface with JSON data retuned by external services. This is generated dby the <silk:DataProvider> tag.

Kind: global class

Methods and Event

new DataProvider(id, options)

Returns a DataProvider instance.

Param
Type
Default
Description

id

String

Unique identifier.

options

Object

Object containing the DataProvider configuration options.

[opsions.servicePath]

String

The url to the service providing the data.

[options.selectName]

String

The ORM's selectName used to extract the data.

[options.treeData]

Boolean

false

Indicates if the data will be treated as a hirargical structure.

[options.markDeleted]

Boolean

flase

Indicated that records will display like a deletion but marked deleted in the database.

[options.isPublic]

Integer

0

Indicates if the service is publicly available.

[options.debugLevel]

Integer

0

Define the debuging level. Currently only level 4 is avaialable.

[options.pkColumn]

String

The primary key column of the table accesed.

[option.detailDP]

String

The name of the DataProvider which contains the detail data of the selected record.

[option.recordSync]

Boolan

Indicates if the dataProvider will sync the records with the data from a recordsync data providers. The execution of a record sync triggers a second click event in the table.

[option.dpSort]

Boolean

Indicates if the sorting will happen in the data provider.

addComponent(component)

Adds a component to the components list.

Kind: instance method of DataProvider

Param
Description

component

The component to be added

batch()

Submits multiple operations loaded into the Operations array to perform a batch request.

Kind: instance method of DataProvider

clean()

Cleans the data from the returnObject.

Kind: instance method of DataProvider

cleanOperations(init)

Cleans the operation list and add a default select action

Kind: instance method of DataProvider

Param
Type
Description

init

boolean

(optional) Defaul is false. If the init parameter is true it will initialize an empty select action. This is used to initialze the request object as "select".

cleanParameters()

Cleans the parameter list from the requestObject.

Kind: instance method of DataProvider

delete(recordIndex)

Executes a DELETE request. Operation items should be added before calling this method. if markDeleted is true it will execute a delete in the local data, but an update in the database.

Kind: instance method of DataProvider

Param
Type
Description

recordIndex

ingeger

(optional) The index of the item to be deleted

exec(operation)

Executes a ORM Operation. If this required parameters these should be added in the "beforeLoad" or "beforeExec" events.

Kind: instance method of DataProvider

Param
Type
Description

operation

String

The operation name in the ORM object to be executed.

getComponents()

Returns the array containing the components which will be notify of changes in the data provider. The component must have a load() function.

Kind: instance method of DataProvider

getIndex(pkValue)

Returns the index position in the data array of the primay key provided

Kind: instance method of DataProvider

Param
Type
Description

pkValue

String

The primary key value to search for.

getIndexItem(pkValue)

Returns the item object of the primary key provided

Kind: instance method of DataProvider

Param
Type
Description

pkValue

String

The primary key value to search for.

getIndexItemOf(columnName, value)

Returns the item object matching the columnName and the value.

Kind: instance method of DataProvider

Param
Type
Description

columnName

String

The column name use to filter

value

Object

The value use to filter.

getIndexOf(columnName, value)

Returns the index position in the data array of the item matching the columnName and the value.

Kind: instance method of DataProvider

Param
Type
Description

columnName

String

The column name use to filter

value

Object

The value use to filter.

getItem(column)

Gets the column's value of the first item. If column is not provided returns the object item of the first position.

Kind: instance method of DataProvider

Param
Type
Description

column

String

(optional) Column name which value will be returned

getItemAt(index, column) ⇒ Object

Gets the column's value at the provided position. If column is not provided returns the object a the provided position.

Kind: instance method of DataProvider

Param
Type
Description

index

Integer

Data index position to be returned

column

String

(optional) Column name which value will be returned

getOperationItem()

Gets the operation Item.

Kind: instance method of DataProvider

getPkColumn()

Gets the name of the primary key column.

Kind: instance method of DataProvider

getPKValue()

Gets the primary key value of the seleced data item.

Kind: instance method of DataProvider

getSelectedItem(columnName)

Gets the selected item based on the selecteIndex property. By default return the firt item if exists.

Kind: instance method of DataProvider

Param
Type
Description

columnName

String

The column to return. If not provided return the item object.

getSelectName()

Gets the selectedName used to load data.

Kind: instance method of DataProvider

getService()

Gets the service path.

Kind: instance method of DataProvider

getSortColumn() ⇒ String

Returns the sorting column name.

Kind: instance method of DataProvider Returns: String - - Column name

getSortDirection() ⇒ Integer

Gets the sorting direction. 1 is accedant, and -1 descendant.

Kind: instance method of DataProvider Returns: Integer - - Sorting Direction

getSQLSortColumn() ⇒ String

Returns the sorting column name with added SQL key words 'asc' or 'desc' based on the sorting direction. If the sorting column is composite ("column, column") it will return the composite column without the SQL direction key words.

Kind: instance method of DataProvider Returns: String - - Column name

insert()

Executes an INSERT request. Operation items should be added before calling this method.

Kind: instance method of DataProvider

isTreeData()

Return a boolean indicating if the data is set to be tree structured

Kind: instance method of DataProvider

langID

The langID is use to overwrite the session loaded langID.

Kind: instance property of DataProvider

length()

Returns the number of records in the data array.

Kind: instance method of DataProvider

load(internalCall)

Submits operations and loads result from the ORM service.

Kind: instance method of DataProvider

Param
Type
Description

internalCall

boolean

True if call internally within the DataProvider

on

Extends the "on" method from the eventManager Class.

Kind: instance property of DataProvider

Param
Type
Description

eventName

String

The event's name.

eventFunction

function

The function to be triggered.

operationObject

The ReturnObject contaiing the returned data after INSERT, UPDATE, DELETE, EXEC, BATCH.

Kind: instance property of DataProvider

recordSync()

Executes the SELECT used to sync the loaded record with the new database record data. This will only affect the selected item. If the SELECT requires parameters these should be added using the "beforeRecordSync" event.

Kind: instance method of DataProvider

select(newSelectName)

Executes a SELECT request. If required parameters should be added before calling this method.

Kind: instance method of DataProvider

Param
Type
Description

newSelectName

String

(optional) The name of the select to be used fro the ORM.

selectObject

The ReturnObject containing the returned data from the database after a SELECT.

Kind: instance property of DataProvider

setItem(column, value)

Sets the column's value of the first item.

Kind: instance method of DataProvider

Param
Type
Description

column

String

The target column.

value

Stting

The value.

setItemAt(index, column, value)

Sets the column's value of the array item defind by the index position.

Kind: instance method of DataProvider

Param
Type
Description

index

Integer

Array index target.

column

String

The target column.

value

Stting

The value.

setOperationAction(action, operation)

Sets the action for the operation object

Kind: instance method of DataProvider

Param
Type
Description

action

String

The action to execute: select, insert, update, delete, exec, batch.

operation

String

(optional) The name of the operation when action is set to exec.

setOperationItem(column, value)

Sets a column items to the operation object

Kind: instance method of DataProvider

Param
Description

column

The column name

value

The value

setParameter(column, value, type, secure)

Sets a parameter. If the parameter already exist it gets updated.

Kind: instance method of DataProvider

Param
Type
Description

column

String

The column name

value

Object

The value

type

String

(optional) One character value (S,I,N,D,T) to force data convertion

secure

booelan

(optional) To inndicates if the value is encrypted. To overwrite what has been define in the ORM.

setSelectName(newSelectName)

Set a new selectName value

Kind: instance method of DataProvider

Param
Type
Description

newSelectName

String

The new select name.

setSortColumn(column, direction)

Sets the sorting column and direction. The direction is optional. If the sorting happens in the database then before execting a select the sort column has to be setup.

Kind: instance method of DataProvider

Param
Type
Description

column

String

Column name

direction

Integer

Sorting directionn. 1 - accedant, -1 is descendant

setTimeout()

The number of milliseconds beore triggering a timeout error.

Kind: instance method of DataProvider

size()

Returns the number of records in the data array.

Kind: instance method of DataProvider

sort(column)

Sorts the data by the provided column. This does not work if the dataProvider is set to treeData="true".

Kind: instance method of DataProvider

Param
Type
Description

column

String

Column to sort

sourceType

Source Type: SQL : From SQL database Local : loaded using laodJSON method. Data is provided as part of the data provider. JSON : data form a JSON file.

Kind: instance property of DataProvider

update(recordIndex)

Executes an UPDATE request. Operation items should be added before calling this method.

Kind: instance method of DataProvider

Param
Type
Description

recordIndex

ingeger

(optional) The index of the item to be updated

on:afterBatch

Event triggered after the batch action is executed. Created with the DataProvider.on("afterBatch", function(){}) method.

Kind: event emitted by DataProvider

on:afterDelete

Event triggered after the delete action is executed. Created with the DataProvider.on("afterDelete", function(){}) method.

Kind: event emitted by DataProvider

on:afterExec ([operation])

Event triggered after the exec action is executed. Created with the DataProvider.on("afterExec", function(){}) method.

Kind: event emitted by DataProvider

Param
Type
Description

[operation]

String

The operation to be executed.

on:afterInsert

Event triggered after the insert action is executed. Created with the DataProvider.on("afterInsert", function(){}) method.

Kind: event emitted by DataProvider

on:afterLoad ([action], [operation])

Event triggered after the load action is executed. Created with the DataProvider.on("afterLoad", function(action,operation){}) method.

Kind: event emitted by DataProvider

Param
Type
Description

[action]

String

The action to be executed.

[operation]

String

The operation to be executed.

on:afterSelect ([selectName])

Event triggered after the select action is executed. Created with the DataProvider.on("afterSelect", function(selectName){}) method.

Kind: event emitted by DataProvider

Param
Type
Description

[selectName]

String

The name of the select with in the ORM to be executed.

on:afterUpdate

Event triggered after the update action is executed. Created with the DataProvider.on("afterUpdate", function(){}) method.

Kind: event emitted by DataProvider

on:beforeBatch

Event triggered before the batch action is executed. Created with the DataProvider.on("beforeBatch", function(){}) method.

Kind: event emitted by DataProvider

on:beforeDelete

Event triggered before the delete action is executed. Created with the DataProvider.on("beforeDelete", function(){}) method.

Kind: event emitted by DataProvider

on:beforeExec ([operation])

Event triggered before the exec action is executed. Created with the DataProvider.on("beforeExec", function(){}) method.

Kind: event emitted by DataProvider

Param
Type
Description

[operation]

String

The operation to be executed.

on:beforeInsert

Event triggered before the insert action is executed. Created with the DataProvider.on("beforeInsert", function(){}) method.

Kind: event emitted by DataProvider

on:beforeLoad ([action], [operation])

Event triggered before the load action is executed. Created with the DataProvider.on("beforeLoad", function(action,operation){}) method.

Kind: event emitted by DataProvider

Param
Type
Description

[action]

String

The action to be executed.

[operation]

String

The operation to be executed.

on:beforeRecordSync ([selectName])

Event triggered before the record sync action is executed. Created with the DataProvider.on("beforeRecordSync", function(selectName){}) method.

Kind: event emitted by DataProvider

Param
Type
Description

[selectName]

String

The name of the select with in the ORM to be executed.

on:beforeSelect ([selectName])

Event triggered before the select action is executed. Created with the DataProvider.on("beforeSelect", function(selectName){}) method.

Kind: event emitted by DataProvider

Param
Type
Description

[selectName]

String

The name of the select with in the ORM to be executed.

on:beforeUpdate

Event triggered before the update action is executed. Created with the DataProvider.on("beforeUpdate", function(){}) method.

Kind: event emitted by DataProvider

on:error (error)

Event triggered when an error has occurred. Created with the DataProvider.on("error", function(errorObject){}) method. If the event returns an object this will replaced the existing returnObject.

Kind: event emitted by DataProvider

Param
Type
Description

error

Object

The returned error object.

on:processLoadedData (returnObject) ⇒ Object

Event triggered when the extracted data is being processed. Created with the DataProvider.on("processLoadedData", function(returnObject){}) method. If the event returns an object this will replaced the existing returnObject.

Kind: event emitted by DataProvider

Param
Type
Description

returnObject

Object

The return objected to be operated.