API Docs for: 1.0.6
Show:

DataTable Class

Defined in: src\jsDataSet.js:908
Module: DataRow
Parent Module: DataSet

A DataTable is s collection of ObjectRow and provides information about the structure of logical table

Methods

acceptChanges

()

Accept any changes setting all dataRows in the state of 'unchanged'. Deleted rows become detached and are removed from the table

add

(
  • obj
)

Adds an object to the table setting the datarow in the state of "added"

Parameters:

Returns:

DataRow created

assignField

(
  • r
  • field
  • value
)

Assign a value to a field and update all dependencies

Parameters:

autoIncrement

(
  • fieldName
  • [autoIncrementInfo]
)
| AutoIncrementColumn

Get/Set autoincrement properties of fields

Parameters:

  • fieldName String
  • [autoIncrementInfo] Object optional

    //see AutoIncrementColumn properties for details

Returns:

avoidCollisions

(
  • r
  • field
  • value
)

check if changing a key field of a row it would collide with come autoincrement field. If it would, recalculates colliding rows/filter in accordance

Parameters:

avoidCollisionsOnField

(
  • field
  • filter
)
private

Recalculate a field to avoid collisions on some rows identified by a filter

Parameters:

cachedMaxSubstring

(
  • field
  • start
  • len
  • filter
)
Number

Evaluates the max of an expression eventually using a cached value

Parameters:

Returns:

calcTemporaryId

(
  • r
  • [field]
)

Augment r[field] in order to avoid collision with another row that needs to take that value if field is not specified, this is applied to all autoincrement field of the table Precondition: r[[field] should be an autoincrement field

Parameters:

cascadeAssignField

(
  • r
  • parentField
  • value
)
private

assign a value to a field in a row and all descending child rows

Parameters:

childRelations

()

Get all relation where THIS table is the parent and another table is the child

Returns:

DataRelation[]

clear

()

Clears the table detaching all rows.

clearDefaults

()

Clears any stored default value for the table

clearMaxCache

()

Clear evaluated max cache

clone

() DataTable

clones table structure without copying any DataRow

Returns:

collisionFilter

(
  • r
  • field
  • value
  • autoInfo
)
SqlFun private

Gets a filter of colliding rows supposing to change r[field]= value, on a specified column

Parameters:

Returns:

SqlFun:

columnList

()

get the list of columns or * if there is no column set

Returns:

string

defaults

(
  • [def]
)
Object |

Get/set the object defaults in a JQuery fashioned style. When def is present, its fields and values are merged into existent defaults.

Parameters:

Returns:

Object | :

denyClear

(
  • [arg]
)
| String

Get/Set DenyClear. === y avoid to clear table on backend reads

Parameters:

Returns:

| String:

detach

(
  • obj
)

Detaches a row from the table

Parameters:

existingRow

(
  • obj
)
DataRow | undefined

check if a row is present in the table. If there is a key, it is used for finding the row, otherwise a ==== comparison is made

Parameters:

Returns:

fieldDependencies

(
  • field
)
String[] private

Gets all autoincrement fields that depends on a given field, i.e. those having field as selector or prefixfield

Parameters:

Returns:

getAutoIncrementColumns

()

Gets all autoincrement column names of this table

Returns:

string[]

getChanges

() Array

gets an array of all modified/added/deleted rows

Returns:

getMaxExpr

(
  • field
  • expr
  • filter
)
Number

gets the max in cache for a field and updates the cache

Parameters:

Returns:

hasChanges

() Boolean

Check if any DataRow in the table has changes

Returns:

importRow

(
  • row
)
DataRow

import a row preserving it's state, the row should already have a DataRow attached

Parameters:

Returns:

DataRow:

created

isOptimized

() Boolean

Check if this table is optimized

Returns:

key

(
  • [k]
)
| String[]

Get/Set the primary key in a Jquery fashioned style. If k is given, the key is set, otherwise the existing key is returned

Parameters:

Returns:

keyFilter

(
  • row
)
| SqlFun

Get the filter that compares key fields of a given row

Parameters:

Returns:

| SqlFun:

load

(
  • obj
  • [safe=true]
)
DataRow

Adds an object to the table setting the datarow in the state of "unchanged"

Parameters:

  • obj Object

    plain object to load in the table

  • [safe=true] Boolean optional

    if false doesn't verify existence of row

Returns:

DataRow:

created DataRow

loadArray

(
  • arr
  • safe
)

Adds an object to the table setting the datarow in the state of 'unchanged'

Parameters:

  • arr Object[]

    array of plain objects

  • safe Boolean

    if false doesn't verify existence of row

Returns:

makeChild

(
  • childRow
  • parentTable
  • [parentRow]
)

Make childRow child of parentRow if a relation between the two is found

Parameters:

mergeArray

(
  • arr
  • overwrite
)

adds an array of objects to collection, as unchanged, if they still are not present. Existence is verified basing on key

Parameters:

Returns:

:

mergeAsPatch

(
  • t
)

merges changes from dataTable t assuming they are unchanged and they are all present in this dataTable. Rows are updated, but only fields actually present in d are modified. Other field are left unchanged. It is assumed that "this" dataTable is unchanged at the beginning

Parameters:

mergeAsPost

(
  • t
)

merges changes from dataTable t assuming they are unchanged and they are not present in this dataTable. Rows are all added 'as is' to this, in the state of ADDED It is assumed that "this" dataTable is unchanged at the beginning

Parameters:

mergeAsPut

(
  • t
)

merges changes from dataTable t assuming they are unchanged and they can be present in this or not. If a row is not present, it is added. If it is present, it is updated. It is assumed that "this" dataTable is unchanged at the beginning

Parameters:

minimumTempValue

(
  • field
  • [value]
)

get/set the minimum temp value for a field, assuming 0 if undefined

Parameters:

newRow

(
  • [obj]
  • [parentRow]
)
Object

creates a DataRow and returns the created object. The created object has the default values merged to the values in the optional parameter obj.

Parameters:

  • [obj] Object optional

    contains the initial value of the created objects.

  • [parentRow] ObjectRow optional

Returns:

parentRelations

()

Get all relation where THIS table is the child and another table is the parent

Returns:

DataRelation[]

postingTable

() String public

Returns the table that should be used for writing, using tableForReading as a default for tableForWriting, or this.name if none of them is set

Returns:

realTable

(
  • [arg]
)
Null | String

Get/Set a table name, that represents the real table associated to the table

Parameters:

Returns:

Null | String:

rejectChanges

()

Reject any changes putting all to 'unchanged' state. Added rows become detached.

safeAssign

(
  • r
  • field
  • value
)

Assign a field assuring it will not cause duplicates on table's autoincrement fields

Parameters:

Returns:

:

select

(
  • [filter]
)
ObjectRow[]

Extract a set of rows matching a filter function - skipping deleted rows

Parameters:

  • [filter] SqlFun optional

Returns:

selectAll

(
  • filter
)
ObjectRow[]

Extract a set of rows matching a filter function - including deleted rows

Parameters:

  • filter SqlFun

Returns:

setMaxExpr

(
  • field
  • expr
  • filter
  • num
)

Set a value in the max cache

Parameters:

  • field String
  • expr SqlFun
  • filter SqlFun
  • num Int

setOptimize

(
  • value
)

Mark the table as optimized / not optimized An optimized table has a cache for all autoincrement field

Parameters:

(
  • o
)

Parameters:

skipInsertCopy

(
  • [arg]
)
| Boolean

Get/Set a flag indicating that this table is not subjected to the Insert and Copy function

Parameters:

Returns:

| Boolean:

skipSecurity

(
  • [arg]
)
| Boolean

Get/Set a flag indicating that this table is not subjected to security functions in a Jquery fashioned style

Parameters:

Returns:

| Boolean:

staticFilter

(
  • [filter]
)
SqlFun

Get/Set a static filter to be used to read data from database in a Jquery fashioned style

Parameters:

  • [filter] SqlFun optional

Returns:

SqlFun:

tableForReading

(
  • [tableName]
)
| DataTable.myTableForReading | DataTable.name

Get/Set the name of table to be used to read data from database in a Jquery fashioned style

Parameters:

Returns:

| DataTable.myTableForReading | DataTable.name:

tableForWriting

(
  • [tableName]
)
| DataTable.myTableForWriting | DataTable.name

Get/Set the name of table to be used to write data from database in a Jquery fashioned style

Parameters:

Returns:

| DataTable.myTableForWriting | DataTable.name:

toString

() String

Debug-helper function

Returns:

updateDependencies

(
  • row
  • field
)

Re calculate temporaryID affected by a field change. It should be done for every autoincrement field that has that field as a selector or as a prefix field

Parameters:

Returns:

:

viewTable

(
  • [arg]
)
| String

Get/Set a table name, that represents the view table associated to the table

Parameters:

Returns:

| String:

Properties

autoIncrementColumns

AutoIncrementColumn

columns

DataColumn

Dictionary of DataColumn

dataset

DataSet

DataSet to which this table belongs

maxCache

Object private

myDefaults

Object private

Set of properties to be assigned to new rows when they are created

myKey

String[] private

Array of key column names

name

String

Name of the table

postingOrder

String | string | function

A ordering to use for posting of this table

rows

ObjectRow[]

Collection of rows, each one hiddenly surrounded with a DataRow object