VIDEO-M8
http://www.ajaxvideotutorials.com/V1...InGridPart.swf
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.
Tested this code getting script error and does not work anyone see a problem with it? I copied I thought properly from the video?
http://www.ajaxvideotutorials.com/V1...InGridPart.swf
Properties TAB > afterrowpopulate:
if(e.rowNumber == -1 ) {
var newvalue = this.stateInfo.defaultValue_CustomerId;
var ele = $('{Grid.ComponentName}.V.R'+e.rowNumber+'.CustomerId')
ele.value = newvalue;
Server Side events:
Afterinsertrecord
dim js as c
dim ar as p
ar.defaultValue_CustomerId = e.dataSubmitted.CustomerId
dim json as c
json = vartojson(ar,.f.,.t.)
js = "{grid.object}.setStateInfo(" + json + ") ;"
e.rtc.A_AjaxResponses[].text = js
e.rtc.A.AjaxResponses[..].id = 1
end function
http://www.ajaxvideotutorials.com/V1...InGridPart.swf
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.
Tested this code getting script error and does not work anyone see a problem with it? I copied I thought properly from the video?
http://www.ajaxvideotutorials.com/V1...InGridPart.swf
Properties TAB > afterrowpopulate:
if(e.rowNumber == -1 ) {
var newvalue = this.stateInfo.defaultValue_CustomerId;
var ele = $('{Grid.ComponentName}.V.R'+e.rowNumber+'.CustomerId')
ele.value = newvalue;
Server Side events:
Afterinsertrecord
dim js as c
dim ar as p
ar.defaultValue_CustomerId = e.dataSubmitted.CustomerId
dim json as c
json = vartojson(ar,.f.,.t.)
js = "{grid.object}.setStateInfo(" + json + ") ;"
e.rtc.A_AjaxResponses[].text = js
e.rtc.A.AjaxResponses[..].id = 1
end function
Comment