.rowCreate()

Previous Next

Creates a new record in the data source.

Returns the 'this' object.

Syntax

.rowCreate( options )

 

options   ::=  {

     hostvars: hostvars

,    initialValues:  initial-values

,    rows:  rows

,    before:  before

,    copyValues:  copy-values

,    success:  success-function

,    error:  error-function

}

 

before       ::=  { true | false }

copy-values  ::=  { true | false }

Options is a struct that can have the following items, all of which are optional.

Hostvars is a set of (temporary) name-value pairs that are passed as column values to the record being created. By default, hostvars is the empty set.

Initial-values is a set of (temporary) name-value pairs that override the default initial values of the newly created record. By default, initial-values is the empty set.

Rows is an array of predefined rows to be created.

Before is a boolean that specifies whether the new record must be created before or after the currently selected record. By default, it is created before.

Copy-values is a boolean that specifies whether all field values must be duplicated from the record currently selected, or not. By default, this duplication does not happen.

Success-function is a function called after a record has been successfully created *.

Error-function is a function called if an error occurs.

NOTE: If you pass success-function, you can use the return value of this function to control whether the record is actually created.

 

Example 1

$.udb('EMP').rowCreate({

  success: function(r){

    r.val('NAME','John');

  }

});

 

A shorter version of the above example is:

$.udb('EMP').rowCreate({

  initialValues: { NAME: 'John' }

});

 

 

Example 2

This example creates an array of predefined rows:

$.udb('EMP').rowCreate({

  rows: [

    {

      FIRST_NAME: 'John',

      NAME: 'Smith'

    },

    {

      FIRST_NAME: 'Jane',

      NAME: 'Doe'

    }                              

],

  initialValues: { DEPT: 'Engineering' }

});