OnInitialValueCalculate Event


This event fires before the New Record rows are displayed.


This event can be used to compute the initial values for fields in the Grid.

The following variables are available to you in the event:


The grid component definition


Run-time calculations (allows you to pass data to other event handlers)


A 'dot' variable with initial values for each field.

Setting Field Defaults

Suppose you have a Grid component with the following fields: CustomerId, FirstName, LastName, and Company. The default value for new records for these fields can be calculated in the OnInitialValueCalculate server-side event.

For example, suppose you would like to set the default value for Company to an initial value of 'Alpha Software'. This can be done as follows:

e.newValues.CustomerId = ""
e.newValues.FirstName = ""
e.newValues.LastName = ""
e.newValues.Company = "Alpha Software"

Your event can set any of these properties. If you want to change the default value for the Company field and set a default value for the LastName field, then your event would do this:

e.newValues.Company = "My Company Name"
e.newValues.LastName = "Smith"

Setting State Variables

You can also set state variables in this event. The value of any state variables will be available in all subsequent ajax callbacks (in the e.__si2 object).

To set a state variable:

e._state.myvar1 = "value1"
e._state.myvar2 = "value2"