V11 Default Value for New Records When Doing Data Entry in the Grid Part
Uploaded on Aug 16, 2013 / 215 views / 483 impressions / 0 comments
Description
M8 Setting the Default Values In New Records In Grid Part
The Grid allows you to enter new records directly in the Grid part or in the Detail View part. The Grid builder allows you to specify default values for fields in new records. This can be done by either specifying the field's "Initial Value" property, or by specifying code in the "onInitialValueCalculate" event. In the case where data entry is done in the Grid Part (as opposed to the Detail View), the issue with the "onInitialValueCalculate" event (which is a server-side event) is that it is only called once: when the Grid is initially rendered. So, if you enter a new record and then save that record, the event is not called before the next new record is displayed. This video shows how you can save the value of a field that was just entered inside the Grid's "stateInfo" object, and then use the "afterRowPopulate" event to retrieve that value and use it as a default in the next new record (Note: The .setValue() method is not used to set the value of the field in the new record row because this would cause the new record row to go 'dirty'. Instead we get a pointer to the element and then simply set its value property.