viewmodel.js

Summary
viewmodel.js
Functions
getViewModelByIdGet ViewModel instance by its ID.
ng_ViewModelFormatErrorFormats ViewModel error object to one or more text messages.
ngFieldDefExceptionThis class implements ngFieldDef type exception.
Properties
FieldDefRelated nfFieldDef object.
ErrorException error type flags.
ErrorMessageException error message (optional).
ExtendedInfoException extended error information (optional).
ngFieldDefThis class implements ViewModel field type description object.
Properties
OwnerOwner (usualy ngViewModel) of ngFieldDef.
IDField identifier.
TypeBasic field type.
DataTypeField type identifier.
PrivateFieldDetermines if field is private.
AttrsField extended attributes.
DisplayNameTextual description of field.
SizeField size.
PrecisionField precision.
RequiredIf TRUE, the value of field is required.
NullIfEmptyIf TRUE, the empty value of field is considered as null.
AutoTrimType of automatic string trim.
ReadOnlyIf TRUE, the value cannot be modified.
MinValueMinimal allowed value.
MaxValueMaximum allowed value.
EnumEnumeration of allowed values.
DefaultValueDefault value of field.
ValueValue of field.
Methods
GetDisplayNameGets field DisplayName.
GetTypedValueGets field typed value.
GetTypedDefaultValueGets field typed default value.
GetAttributeGets field attribute.
SetAttributeSets field attribute.
TypedValueConverts given value according to field type.
TypedValueAsConverts given value according to external field type.
ClearSets field value to undefined.
ValidateValidates if given value can be converted according to field type.
FormatErrorFormats ViewModel error object to one or more text messages.
SerializeExports (and converts) given value from ViewModel.
DeserializeImports (and converts) given value to ViewModel.
FormatStringConverts given value to string according to field type.
EditStringConverts given value to string suitable for editation according to field type.
ParseStringConverts given string value to value according to field type.
Events
OnFormatError
OnSerialize
OnDeserialize
OnTypedValue
OnFormatString
OnEditString
OnParseString
ngViewModelThis class implements ViewModel object.
Properties
NamespaceViewModel namespace.
ViewModelViewModel properties.
DefaultValuesHolds default values for non-ngFieldDef properties.
ServerURLViewModel’s server script URL.
ActiveCommandCurrent running server-side command.
Methods
AssignAssigns settings and values from another ViewModel.
SetNamespaceSets ViewModel namespace.
SetViewModelSets ViewModel modification.
SetValuesSets values to ViewModel.
GetValuesGets values from ViewModel.
ScanValuesScans all ViewModel values.
GetFieldByIDGets field in ViewModel based on property ID.
GetFieldValueByIDGets ViewModel value based on property ID.
SetFieldValueByIDSets ViewModel value based on property ID.
ResetResets ViewModel to initial state.
IsValidTests if all (or selected) ViewModel’s properties are valid.
ErrorsGets textual description of ViewModel’s errors.
ShowErrorsDisplays ViewModel errors.
CommandSends command to the server.
CancelCommandCancels running command.
GetCommandValueNamesGets value names for specified command.
GetCommandValueNamesByFieldAttrsGets value names for specified command based on field attribute ‘Command’.
GetRPCGets current ngRPC for ViewModel requests.
Events
OnSetValues
OnSetValue
OnGetValues
OnGetValue
OnCommand
OnGetCommandValueNames
OnDoCommand
OnCommandRequest
OnCommandResults
OnCommandFinished
OnCommandCancel
OnCommandData
OnSetViewModel
OnViewModelChanged
OnResults
OnErrors
OnShowErrors
OnAssign
ngDataSetFieldDefngViewModel DataSet field (based on ngFieldDef ARRAY).
Properties
DataSetNeedUpdateIndicates if fresh data is requested from server on data update.
Methods
InvalidateDataSetIndicated that fresh data is requested from server on data update.
ngLookupFieldDefngViewModel Lookup field (based on ngFieldDef ARRAY).
Properties
DataSetNeedUpdateIndicates if fresh data is requested from server on data update.
Methods
InvalidateDataSetIndicated that fresh data is requested from server on data update.
Knockout extensionsThis extends Knockout functions for viewmodel definition.
Functions
ko.ng_noserializeMarks viewmodel property as non-serializable.
ko.ng_serializeMarks viewmodel property as serializable.
ko.ng_delegateCreates computed viewmodel property which value is gathered from another model.
ko.ng_bool2valCreates computed viewmodel property which translates boolean to other viewmodel property value (or values).
ko.ng_sprintfCreates computed viewmodel property which formats string (PHP like sprintf function) based on values of other viewmodel properties.
ko.ng_changedCreates computed viewmodel property which detects value changes of enumerated properties.
ko.ng_dataversionCreates computed viewmodel property, similar to ko.ng_changed, which detects value changes of enumerated properties and increases it’s value every time the change occurs.
ko.ng_matchesCreates computed viewmodel property which is set to TRUE if all enumerated properties equals to specified values.
ko.ng_matches_oneCreates computed viewmodel property which is set to TRUE if at least one of enumerated properties equal to specified value.
ko.ng_timerCreates computed viewmodel property which is repeatedly updated on specified interval.
ko.ng_lookupCreates computed viewmodel property which transforms value of given property to value in lookup table.
ko.ng_fielddefEncapsulates ngFieldDef into viewmodel.

Functions

getViewModelById

function getViewModelById(id)

Get ViewModel instance by its ID.

Syntax: object getViewModelById (string id)

Returns

ViewModel instance or null if viewmodel not found.

ng_ViewModelFormatError

function ng_ViewModelFormatError(err)

Formats ViewModel error object to one or more text messages.

Syntax: array ng_ViewModelFormatError (object error)

Parameters

errorViewModel error object (ngFieldDefException or array of ngFieldDefExceptions)

Returns

Array of formated string messages.

ngFieldDefException

This class implements ngFieldDef type exception.

Summary
Properties
FieldDefRelated nfFieldDef object.
ErrorException error type flags.
ErrorMessageException error message (optional).
ExtendedInfoException extended error information (optional).

Properties

FieldDef

this.FieldDef

Related nfFieldDef object.  Type: object

Error

this.Error

Exception error type flags.  Type: object

Constants

FIELDDEF_ERRunspecified error
FIELDDEF_ERR_TYPEtype conversion exception
FIELDDEF_ERR_EMPTYfield is empty
FIELDDEF_ERR_MINvalue is lower than minimal allowed
FIELDDEF_ERR_MAXvalue is lower than maximum allowed
FIELDDEF_ERR_ENUMvalue is not one of allowed
FIELDDEF_ERR_LENlength of value exceeds allowed

ErrorMessage

this.ErrorMessage

Exception error message (optional).  Type: string

ExtendedInfo

this.ExtendedInfo

Exception extended error information (optional).  Type: mixed

ngFieldDef

This class implements ViewModel field type description object.

Summary
Properties
OwnerOwner (usualy ngViewModel) of ngFieldDef.
IDField identifier.
TypeBasic field type.
DataTypeField type identifier.
PrivateFieldDetermines if field is private.
AttrsField extended attributes.
DisplayNameTextual description of field.
SizeField size.
PrecisionField precision.
RequiredIf TRUE, the value of field is required.
NullIfEmptyIf TRUE, the empty value of field is considered as null.
AutoTrimType of automatic string trim.
ReadOnlyIf TRUE, the value cannot be modified.
MinValueMinimal allowed value.
MaxValueMaximum allowed value.
EnumEnumeration of allowed values.
DefaultValueDefault value of field.
ValueValue of field.
Methods
GetDisplayNameGets field DisplayName.
GetTypedValueGets field typed value.
GetTypedDefaultValueGets field typed default value.
GetAttributeGets field attribute.
SetAttributeSets field attribute.
TypedValueConverts given value according to field type.
TypedValueAsConverts given value according to external field type.
ClearSets field value to undefined.
ValidateValidates if given value can be converted according to field type.
FormatErrorFormats ViewModel error object to one or more text messages.
SerializeExports (and converts) given value from ViewModel.
DeserializeImports (and converts) given value to ViewModel.
FormatStringConverts given value to string according to field type.
EditStringConverts given value to string suitable for editation according to field type.
ParseStringConverts given string value to value according to field type.
Events
OnFormatError
OnSerialize
OnDeserialize
OnTypedValue
OnFormatString
OnEditString
OnParseString

Properties

Owner

this.Owner

Owner (usualy ngViewModel) of ngFieldDef.  Type: object

ID

this.ID

Field identifier.  Type: string

Type

this.Type

Basic field type.  Type: string

Constants

’BOOL’boolean type
’INTEGER’integer type
’FLOAT’float number type
’SBYTE’signed byte (-127..127)
’BYTE’unsigned byte (0..255)
’SHORT’signed short (-32767..32767)
’USHORT’unsigned short (0-65535)
’LONG’signed long (-2147483647..2147483647)
’ULONG’unsigned long (0..4294967295)
’DECIMAL’number with fixed decimal
’STRING’string type
’NVARCHAR’string type with limited length
’TIMESTAMP’date and time type
’DATETIME’date and time type
’DATE’date only type
’TIME’time only type
’UTCTIMESTAMP’date and time type (UTC)
’UTCDATETIME’date and time type (UTC)
’UTCDATE’date only type (UTC)
’UTCTIME’time only type (UTC)
’ARRAY’array type

DataType

this.DataType

Field type identifier.  Type: string

PrivateField

this.PrivateField

Determines if field is private.  Private fields are never sent to server.  Type: boolean Default value: false

Attrs

this.Attrs

Field extended attributes.  Type: object Default value: {}

DisplayName

Textual description of field.  Type: string Default value: undefined

Size

Field size.  Type: integer Default value: undefined

Precision

Field precision.  Type: integer Default value: undefined

Required

this.Required

If TRUE, the value of field is required.  Type: boolean Default value: false

NullIfEmpty

this.NullIfEmpty

If TRUE, the empty value of field is considered as null.  Type: boolean Default value: true

AutoTrim

Type of automatic string trim.  Type: integer Default value: fdTrim

Constants

fdNoTrimdon’t trim
fdTrimtrim leading and trailing spaces
fdLeftTrimtrim leading spaces
fdRightTrimtrim trailing spaces

ReadOnly

If TRUE, the value cannot be modified.  Type: string Default value: undefined

MinValue

Minimal allowed value.  Type: mixed Default value: undefined

MaxValue

Maximum allowed value.  Type: mixed Default value: undefined

Enum

Enumeration of allowed values.  Type: array Default value: undefined

DefaultValue

Default value of field.  Type: mixed Default value: undefined

Value

this.Value

Value of field.  Type: mixed Default value: undefined

Methods

GetDisplayName

Gets field DisplayName.

Syntax

string GetDisplayName ([bool substid=true])

Parameters

substidif TRUE, returns field ID if display name is not defined

Returns

The field display name.

GetTypedValue

Gets field typed value.

Syntax

mixed GetTypedValue ()

Returns

The field value.

GetTypedDefaultValue

Gets field typed default value.

Syntax

mixed GetTypedDefaultValue ()

Returns

The field default value.

GetAttribute

Gets field attribute.

Syntax

mixed GetAttribute (string attr)

Parameters

attrattribute id

Returns

The value of specified attribute.

SetAttribute

Sets field attribute.

Syntax

void SetAttribute (string attr, mixed value)

Parameters

attrattribute id
valueattribute value

Returns

-

TypedValue

Converts given value according to field type.

Syntax

mixed TypedValue (mixed value)

Parameters

valuevalue to convert

Returns

Converted value or throws ngFieldDefException if convert fails.

TypedValueAs

Converts given value according to external field type.

Syntax

mixed TypedValueAs (mixed value, ngFieldDef field)

Parameters

valuevalue to convert
fieldfield to which type value should be converted

Returns

Converted value or throws ngFieldDefException if convert fails.  Thrown exception has reference to this field, not external.

Clear

Sets field value to undefined.

Syntax

void Clear (void)

Returns

-

Validate

Validates if given value can be converted according to field type.

Syntax

mixed Validate (mixed value)

Parameters

valuevalue to test

Returns

TRUE if value can be converted or ngFieldDefException object with description of conversion failure.

FormatError

Formats ViewModel error object to one or more text messages.

Syntax

array FormatError (object error)

Parameters

errorViewModel error object (ngFieldDefException or array of ngFieldDefExceptions)

Returns

Array of formated string messages.

Serialize

Exports (and converts) given value from ViewModel.

Syntax

mixed Serialize (mixed value)

Parameters

valuevalue to serialize

Returns

Exported value or throws ngFieldDefException if convert fails.

Deserialize

Imports (and converts) given value to ViewModel.

Syntax

mixed Deserialize (mixed value)

Parameters

valuevalue to deserialize

Returns

Imported value or throws ngFieldDefException if convert fails.

FormatString

Converts given value to string according to field type.

Syntax

string FormatString (mixed value)

Parameters

valuevalue to convert

Returns

String value.

EditString

Converts given value to string suitable for editation according to field type.

Syntax

string EditString (mixed value)

Parameters

valuevalue to convert

Returns

String value for edit.

ParseString

Converts given string value to value according to field type.

Syntax

mixed ParseString (string str)

Parameters

strstring value

Returns

Value according to field type.

Events

OnFormatError

OnSerialize

OnDeserialize

OnTypedValue

OnFormatString

OnEditString

OnParseString

ngViewModel

This class implements ViewModel object.

Summary
Properties
NamespaceViewModel namespace.
ViewModelViewModel properties.
DefaultValuesHolds default values for non-ngFieldDef properties.
ServerURLViewModel’s server script URL.
ActiveCommandCurrent running server-side command.
Methods
AssignAssigns settings and values from another ViewModel.
SetNamespaceSets ViewModel namespace.
SetViewModelSets ViewModel modification.
SetValuesSets values to ViewModel.
GetValuesGets values from ViewModel.
ScanValuesScans all ViewModel values.
GetFieldByIDGets field in ViewModel based on property ID.
GetFieldValueByIDGets ViewModel value based on property ID.
SetFieldValueByIDSets ViewModel value based on property ID.
ResetResets ViewModel to initial state.
IsValidTests if all (or selected) ViewModel’s properties are valid.
ErrorsGets textual description of ViewModel’s errors.
ShowErrorsDisplays ViewModel errors.
CommandSends command to the server.
CancelCommandCancels running command.
GetCommandValueNamesGets value names for specified command.
GetCommandValueNamesByFieldAttrsGets value names for specified command based on field attribute ‘Command’.
GetRPCGets current ngRPC for ViewModel requests.
Events
OnSetValues
OnSetValue
OnGetValues
OnGetValue
OnCommand
OnGetCommandValueNames
OnDoCommand
OnCommandRequest
OnCommandResults
OnCommandFinished
OnCommandCancel
OnCommandData
OnSetViewModel
OnViewModelChanged
OnResults
OnErrors
OnShowErrors
OnAssign

Properties

Namespace

this.Namespace

ViewModel namespace.  Type: string Default value: ’’

ViewModel

this.ViewModel

ViewModel properties.  Type: object Default value: { }

DefaultValues

this.DefaultValues

Holds default values for non-ngFieldDef properties.  Type: object Default value: { }

ServerURL

this.ServerURL

ViewModel’s server script URL.  Type: string Default value: ’’

ActiveCommand

this.ActiveCommand

Current running server-side command.  Type: string Default value: ’’

Methods

Assign

Assigns settings and values from another ViewModel.

Syntax

void Assign (ngViewModel vm)

Parameters

vmsource viewmodel

Returns

-

SetNamespace

Sets ViewModel namespace.  If specified namespace is registered, the settings of viewmodel is copied from registered namespace.

Syntax

void SetNamespace (string ns)

Parameters

nsnamespace

Returns

-

SetViewModel

Sets ViewModel modification.

Syntax

void SetViewModel (mixed vm)

Parameters

vmobject containing new properties of viewmodel or function which adds new properties to viewmodel

Returns

-

SetValues

Sets values to ViewModel.

Syntax

void SetValues (object values)

Parameters

valuesobject containing new values

Returns

-

GetValues

Gets values from ViewModel.

Syntax

void GetValues ([bool writableonly=false, array valuenames=undefined, object errors={}, bool convtimestamps=false])

Parameters

writableonlyif TRUE, return only values of non-read-only properties
valuenamesoptional list of property names, returned values are only from properties specified on this list
errorsall errors which occured during serialization (including type conversion erros) are recorded into this object as name-value pairs “property path”:”exception”
convtimestampsif TRUE, values of type Date are returned as timestamps (integer)

Returns

Object containing values.

ScanValues

Scans all ViewModel values.

Syntax

void ScanValues (function callback)

Parameters

callbackfunction which is called on each ViewModel value

Returns

-

Callback

function callback (ngViewModel vm, mixed value, ngFieldDef instance, string propid)

Callback parameters

vmViewModel on which is scan performed
valueobservable or value
instancengFieldDef or same as value
propidproperty ID (including path) in ViewModel

Callback returns

TRUE, if continue scan.

GetFieldByID

Gets field in ViewModel based on property ID.

Syntax

mixed GetFieldByID (string propid)

Parameters

propidproperty ID (including path) in ViewModel

Returns

ViewModel property.

GetFieldValueByID

Gets ViewModel value based on property ID.

Syntax

mixed GetFieldValueByID (string propid)

Parameters

propidproperty ID (including path) in ViewModel

Returns

Value of property.

SetFieldValueByID

Sets ViewModel value based on property ID.

Syntax

void SetFieldValueByID (string propid, mixed value)

Parameters

propidproperty ID (including path) in ViewModel
valueproperty value

Returns

-

Reset

Resets ViewModel to initial state.

Syntax

void Reset ([function callback])

Parameters

callbackoptional callback function which is called before value is reset

Returns

-

Callback

function callback (ngViewModel vm, mixed value, ngFieldDef instance, string propid)

Callback parameters

vmViewModel on which is scan performed
valueobservable or value
instancengFieldDef or same as value
propidproperty ID (including path) in ViewModel

Callback returns

If FALSE, reset of the property will be skipped

IsValid

Tests if all (or selected) ViewModel’s properties are valid.

Syntax

mixed IsValid ([bool writableonly=false, array valuenames=undefined])

Parameters

writableonlyif TRUE, return only values of non-read-only properties
valuenamesoptional list of property names, returned values are only from properties specified on this list

Returns

TRUE if ViewModel’s properties are valid or object with errors as name-value pairs “property path”:”exception”.

Errors

Gets textual description of ViewModel’s errors.

Syntax

array Errors ([bool writableonly=false, array valuenames=undefined])

Parameters

writableonlyif TRUE, return only values of non-read-only properties
valuenamesoptional list of property names, returned values are only from properties specified on this list

Returns

Array of formated string messages.

ShowErrors

Displays ViewModel errors.

Syntax

void ShowErrors ([object errors])

Parameters

errorsoptional error object, if not specified the ngViewModel.IsValid is used for getting errors

Returns

TRUE is one or more error present and displayed.

Command

Sends command to the server.

Syntax

void Command (string cmd[, object options])

Parameters

cmdcommand id
optionscommand options

Returns

TRUE if command was sent.

Command options

ValueNamesoptional list of property names; values, which are send to server, are only from properties specified on this list
Valuesoptional object with values which are send to server (ViewModel values are ignored)
URLoptional server URL, default is ServerURL
Paramsoptional request ngRPC parameters

CancelCommand

Cancels running command.

Syntax

void CancelCommand ()

Returns

-

GetCommandValueNames

Gets value names for specified command.

Syntax

mixed GetCommandValueNames (string cmd[, object options, bool exactmatch=false])

Parameters

cmdcommand id
optionscommand options (see Command)
exactmatchreturn only value names which are exactly defined for specified command

Returns

Array of value names to be passed together with command or undefined if no specific value names defined for command (all values are sent to server).

GetCommandValueNamesByFieldAttrs

Gets value names for specified command based on field attribute ‘Command’.

Syntax

mixed GetCommandValueNamesByFieldAttrs (string cmd [, bool exactmatch=false])

Parameters

cmdcommand id
exactmatchreturn only value names which are exactly defined for specified command

Returns

Array of value names to be passed together with command or undefined if no specific value names defined for command (all values are sent to server).

GetRPC

Gets current ngRPC for ViewModel requests.

Syntax

ngRPC GetRPC ()

Returns

Instance of ngRPC.

Events

OnSetValues

OnSetValue

OnGetValues

OnGetValue

OnCommand

OnGetCommandValueNames

OnDoCommand

OnCommandRequest

OnCommandResults

OnCommandFinished

OnCommandCancel

OnCommandData

OnSetViewModel

OnViewModelChanged

OnResults

OnErrors

OnShowErrors

OnAssign

ngDataSetFieldDef

ngViewModel DataSet field (based on ngFieldDef ARRAY).

Syntax

new ngDataSetFieldDef (string id [, object attrs={}])

Parameters

idfield id
attrsfield attributes
Summary
Properties
DataSetNeedUpdateIndicates if fresh data is requested from server on data update.
Methods
InvalidateDataSetIndicated that fresh data is requested from server on data update.

Properties

DataSetNeedUpdate

this.DataSetNeedUpdate

Indicates if fresh data is requested from server on data update.  Type: bool Default value: true

Methods

InvalidateDataSet

Indicated that fresh data is requested from server on data update.

Syntax

void InvalidateDataSet ()

Returns

-

ngLookupFieldDef

ngViewModel Lookup field (based on ngFieldDef ARRAY).

Syntax

new ngLookupFieldDef (string id [, object attrs={}])

Parameters

idfield id
attrsfield attributes
Summary
Properties
DataSetNeedUpdateIndicates if fresh data is requested from server on data update.
Methods
InvalidateDataSetIndicated that fresh data is requested from server on data update.

Properties

DataSetNeedUpdate

this.DataSetNeedUpdate

Indicates if fresh data is requested from server on data update.  Type: bool Default value: true

Methods

InvalidateDataSet

this.InvalidateDataSet = ngfd_InvalidateDataSet; this.DoSerialize = ngfd_DataSetFieldSerialize; this.DoDeserialize = ngfd_DataSetFieldDeserialize; } if(
   typeof ngUserControls = == 'undefined'
) ngUserControls = new Array(); ngUserControls['viewmodel'] =

Indicated that fresh data is requested from server on data update.

Syntax

void InvalidateDataSet ()

Returns

-

Knockout extensions

This extends Knockout functions for viewmodel definition.

Summary
Functions
ko.ng_noserializeMarks viewmodel property as non-serializable.
ko.ng_serializeMarks viewmodel property as serializable.
ko.ng_delegateCreates computed viewmodel property which value is gathered from another model.
ko.ng_bool2valCreates computed viewmodel property which translates boolean to other viewmodel property value (or values).
ko.ng_sprintfCreates computed viewmodel property which formats string (PHP like sprintf function) based on values of other viewmodel properties.
ko.ng_changedCreates computed viewmodel property which detects value changes of enumerated properties.
ko.ng_dataversionCreates computed viewmodel property, similar to ko.ng_changed, which detects value changes of enumerated properties and increases it’s value every time the change occurs.
ko.ng_matchesCreates computed viewmodel property which is set to TRUE if all enumerated properties equals to specified values.
ko.ng_matches_oneCreates computed viewmodel property which is set to TRUE if at least one of enumerated properties equal to specified value.
ko.ng_timerCreates computed viewmodel property which is repeatedly updated on specified interval.
ko.ng_lookupCreates computed viewmodel property which transforms value of given property to value in lookup table.
ko.ng_fielddefEncapsulates ngFieldDef into viewmodel.

Functions

ko.ng_noserialize

ko.ng_noserialize = function (v)

Marks viewmodel property as non-serializable.  Non-serializable properties is not send to server.

Syntax

object ko.ng_noserialize (object vmprop)

Parameters

vmpropviewmodel property

Returns

vmpropthis simplifies function chaining.

ko.ng_serialize

ko.ng_serialize = function (v)

Marks viewmodel property as serializable.  Only serializable properties can be send to server.

Syntax

object ko.ng_serialize (object vmprop)

Parameters

vmpropviewmodel property

Returns

vmpropthis simplifies function chaining.

ko.ng_delegate

ko.ng_delegate = function (viewModel,
propName,
readonly)

Creates computed viewmodel property which value is gathered from another model.

Syntax

function ko.ng_delegate (mixed viewmodel, string propname [, bool readonly])

Parameters

viewmodelstring ID or instance of viewmodel
propnameviewmodel property name in reference viewmodel
readonlyif TRUE, the value in current viewmodel is read-only

Returns

Computed viewmodel property.

ko.ng_bool2val

ko.ng_bool2val = function (viewModel,
propName,
trueValue,
falseValue)

Creates computed viewmodel property which translates boolean to other viewmodel property value (or values).

Syntax

function ko.ng_bool2val (mixed viewmodel, string propname, mixed trueValue [, mixed falseValue])

Parameters

viewmodelstring ID or instance of viewmodel
propnameviewmodel property name in reference viewmodel
trueValuevalue which is translated as TRUE
falseValuevalue which is translated as FALSE

Returns

Computed viewmodel property.

ko.ng_sprintf

ko.ng_sprintf = function ()

Creates computed viewmodel property which formats string (PHP like sprintf function) based on values of other viewmodel properties.

Syntax

function ko.ng_sprintf (mixed viewmodel, string format [, string propname1, string propname2, ...])

Parameters

viewmodelstring ID or instance of viewmodel
formattext with format characters
propname1..Nviewmodel property names, values of these properties are used as arguments for string formating

If any of parameters is indexed array the array items are expanded inline as function parameters.

Returns

Computed viewmodel property.

ko.ng_changed

ko.ng_changed = function ()

Creates computed viewmodel property which detects value changes of enumerated properties.

Syntax

function ko.ng_changed (mixed viewmodel, [, string propname1, string propname2, ...])

Parameters

viewmodelstring ID or instance of viewmodel
propname1..Nviewmodel property names on which change state is maintained

If any of parameters is indexed array the array items are expanded inline as function parameters.

Returns

Computed viewmodel property.

ko.ng_dataversion

ko.ng_dataversion = function ()

Creates computed viewmodel property, similar to ko.ng_changed, which detects value changes of enumerated properties and increases it’s value every time the change occurs.

Syntax

function ko.ng_dataversion (mixed viewmodel, [, string propname1, string propname2, ...])

Parameters

viewmodelstring ID or instance of viewmodel
propname1..Nviewmodel property names on which change state is maintained

If any of parameters is indexed array the array items are expanded inline as function parameters.

Returns

Computed viewmodel property.

ko.ng_matches

ko.ng_matches = function ()

Creates computed viewmodel property which is set to TRUE if all enumerated properties equals to specified values.

Syntax

function ko.ng_matches (mixed viewmodel, string propname1, mixed val1 [, string propname2, mixed val2, ...])

Parameters

viewmodelstring ID or instance of viewmodel
propname1..Nviewmodel property names which values are compared
val1..Nvalues for comparsion, $ can be used to reference other viewmodel property

If any of parameters is indexed array the array items are expanded inline as function parameters.

Returns

Computed viewmodel property.

ko.ng_matches_one

ko.ng_matches_one = function ()

Creates computed viewmodel property which is set to TRUE if at least one of enumerated properties equal to specified value.

Syntax

function ko.ng_matches_one (mixed viewmodel, string propname1, mixed val1 [, string propname2, mixed val2, ...])

Parameters

viewmodelstring ID or instance of viewmodel
propname1..Nviewmodel property names which values are compared
val1..Nvalues for comparsion, $ can be used to reference other viewmodel property

If any of parameters is indexed array the array items are expanded inline as function parameters.

Returns

Computed viewmodel property.

ko.ng_timer

ko.ng_timer = function (interval)

Creates computed viewmodel property which is repeatedly updated on specified interval.  The value of this property is date and time of last update.

Syntax

function ko.ng_timer (int interval)

Parameters

intervalupdate interval in milliseconds

Returns

Computed viewmodel property.

ko.ng_lookup

ko.ng_lookup = function (viewModel,
propname,
lookupviewmodel,
lookuppropname,
lookupkeyfield,
lookupdatafield)

Creates computed viewmodel property which transforms value of given property to value in lookup table.

Syntax

function ko.ng_lookup (mixed viewmodel, string propname, mixed lookupviewmodel, string lookuppropname, string lookupkeyfield=’Value’, lookupdatafield=’Text’)

Parameters

viewmodelstring ID or instance of viewmodel
propnameviewmodel property to be transformed
lookupviewmodelstring ID or instance of lookup viewmodel
lookuppropnamelookup viewmodel property where lookup table is stored
lookupkeyfieldproperty name where key is stored in lookup table
lookupdatafieldproperty name where transformed value is stored in lookup table, if null or undefined the transformed value is whole lookup table item

Returns

Computed viewmodel property.

ko.ng_fielddef

ko.ng_fielddef = function(vm,
fd,
value)

Encapsulates ngFieldDef into viewmodel.

Syntax

ngFieldDef ko.ng_fielddef (mixed viewmodel, ngFieldDef fielddef [, mixed value])

Parameters

viewmodelinstance of viewmodel
fielddefngFieldDef which schould be part of the viewmodel
valueoptional initial value of ngFieldDef

Returns

Encapsulated ngFieldDef as viewmodel property.

function getViewModelById(id)
Get ViewModel instance by its ID.
function ng_ViewModelFormatError(err)
Formats ViewModel error object to one or more text messages.
This class implements ViewModel field type description object.
this.FieldDef
Related nfFieldDef object.
this.Error
Exception error type flags.
this.ErrorMessage
Exception error message (optional).
this.ExtendedInfo
Exception extended error information (optional).
this.Owner
Owner (usualy ngViewModel) of ngFieldDef.
This class implements ViewModel object.
this.ID
Field identifier.
this.Type
Basic field type.
this.DataType
Field type identifier.
this.PrivateField
Determines if field is private.
this.Attrs
Field extended attributes.
this.Required
If TRUE, the value of field is required.
this.NullIfEmpty
If TRUE, the empty value of field is considered as null.
this.Value
Value of field.
this.Namespace
ViewModel namespace.
this.ViewModel
ViewModel properties.
this.DefaultValues
Holds default values for non-ngFieldDef properties.
this.ServerURL
ViewModel’s server script URL.
this.ActiveCommand
Current running server-side command.
Remote Procedure Call.
this.DataSetNeedUpdate
Indicates if fresh data is requested from server on data update.
this.DataSetNeedUpdate
Indicates if fresh data is requested from server on data update.
this.InvalidateDataSet = ngfd_InvalidateDataSet; this.DoSerialize = ngfd_DataSetFieldSerialize; this.DoDeserialize = ngfd_DataSetFieldDeserialize; } if(
   typeof ngUserControls = == 'undefined'
) ngUserControls = new Array(); ngUserControls['viewmodel'] =
Indicated that fresh data is requested from server on data update.
ko.ng_noserialize = function (v)
Marks viewmodel property as non-serializable.
ko.ng_serialize = function (v)
Marks viewmodel property as serializable.
ko.ng_delegate = function (viewModel,
propName,
readonly)
Creates computed viewmodel property which value is gathered from another model.
ko.ng_bool2val = function (viewModel,
propName,
trueValue,
falseValue)
Creates computed viewmodel property which translates boolean to other viewmodel property value (or values).
ko.ng_sprintf = function ()
Creates computed viewmodel property which formats string (PHP like sprintf function) based on values of other viewmodel properties.
ko.ng_changed = function ()
Creates computed viewmodel property which detects value changes of enumerated properties.
ko.ng_dataversion = function ()
Creates computed viewmodel property, similar to ko.ng_changed, which detects value changes of enumerated properties and increases it’s value every time the change occurs.
ko.ng_matches = function ()
Creates computed viewmodel property which is set to TRUE if all enumerated properties equals to specified values.
ko.ng_matches_one = function ()
Creates computed viewmodel property which is set to TRUE if at least one of enumerated properties equal to specified value.
ko.ng_timer = function (interval)
Creates computed viewmodel property which is repeatedly updated on specified interval.
ko.ng_lookup = function (viewModel,
propname,
lookupviewmodel,
lookuppropname,
lookupkeyfield,
lookupdatafield)
Creates computed viewmodel property which transforms value of given property to value in lookup table.
ko.ng_fielddef = function(vm,
fd,
value)
Encapsulates ngFieldDef into viewmodel.
This class implements ngFieldDef type exception.
Tests if all (or selected) ViewModel’s properties are valid.
Sends command to the server.
Close