This may all be easy in ver 10 but for those of us still using ver 9 the following might be worthwhile. It also gave me some insight into custom controls.
I have found it useful to provide users more than one way to submit a grid form which might send them to various other pages depending on which submit button they use. There is a thread "Two submit buttons on a grid�" which does just that. But here I wanted to redirect to the same page but have different actions before leaving the page the user is on. I wanted to use a custom control as a second submit button but still have access to the validations events. All the documentation that I have been able to find, describes how to define a custom control's appearance but not how to actually have the custom control do anything. In fact I have seen statements that a custom control is only for display. I have used javascript in a custom control definition which can access and change the data on the form.
I have a field named "sendit" on my grid. It happens to be a logical and it happens to be hidden and it happens to be in the detail section of the grid but none of these are required. The same grid contains a variable named "signit" as type C but any type would do as it never actually gets any data. Signit is assigned to a custom control defined as follows (all on one line).
Signit_render = <<%html%
<input type="button" value="Save and send to the office." onClick="document.forms['transcripts'].elements['V.R1.SENDIT'].value='T';
document.forms['transcripts'].transcripts_DetailView_Save.click()"
style="BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid;
BACKGROUND-COLOR: #f9ead6; BORDER-RIGHT: 1px solid;
BORDER-: 1px solid">
%html%
When the user clicks the custom control named signit (labeled "Save and send to the office."), two things happen in sequence. First the value of the hidden field "sendit" is set to true and then the code emulates a click of the form submit button (labled "Save"). The emulation is complete and the forms validation events do occur.
The trick is knowing the names of the two objects, the field sendit and the actual submit button. That you can get by examining the source code of the final a5w page in a browser. In this case I found two statements describing the two objects. They were:
<input type="hidden" id="V.R1. SENDIT " name="V.R1. SENDIT " value="False" />
and
<input class="npapnatucketButton" type="submit" value="Save" name="transcripts_DetailView_Save">
So those are the names I used in the inline javascript.
This simple technique has many possibilities. One click of this button could be used to set the values of multiple fields at the same time. Even better is the use of the custom control to set the value of a variable and then have a validate event read the value of that variable and carry out other operations accordingly since you can include almost anything in the validate events using xbasic.
It is also possible to have the javascript in the custom control call a javascript function defined elsewhere on the a5w page but the use of this inline javascript is appealing.
I have benefited greatly from what I have learned from others on this forum and I hope someone can make use of this.
Thanks,
Irwin
I have found it useful to provide users more than one way to submit a grid form which might send them to various other pages depending on which submit button they use. There is a thread "Two submit buttons on a grid�" which does just that. But here I wanted to redirect to the same page but have different actions before leaving the page the user is on. I wanted to use a custom control as a second submit button but still have access to the validations events. All the documentation that I have been able to find, describes how to define a custom control's appearance but not how to actually have the custom control do anything. In fact I have seen statements that a custom control is only for display. I have used javascript in a custom control definition which can access and change the data on the form.
I have a field named "sendit" on my grid. It happens to be a logical and it happens to be hidden and it happens to be in the detail section of the grid but none of these are required. The same grid contains a variable named "signit" as type C but any type would do as it never actually gets any data. Signit is assigned to a custom control defined as follows (all on one line).
Signit_render = <<%html%
<input type="button" value="Save and send to the office." onClick="document.forms['transcripts'].elements['V.R1.SENDIT'].value='T';
document.forms['transcripts'].transcripts_DetailView_Save.click()"
style="BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid;
BACKGROUND-COLOR: #f9ead6; BORDER-RIGHT: 1px solid;
BORDER-: 1px solid">
%html%
When the user clicks the custom control named signit (labeled "Save and send to the office."), two things happen in sequence. First the value of the hidden field "sendit" is set to true and then the code emulates a click of the form submit button (labled "Save"). The emulation is complete and the forms validation events do occur.
The trick is knowing the names of the two objects, the field sendit and the actual submit button. That you can get by examining the source code of the final a5w page in a browser. In this case I found two statements describing the two objects. They were:
<input type="hidden" id="V.R1. SENDIT " name="V.R1. SENDIT " value="False" />
and
<input class="npapnatucketButton" type="submit" value="Save" name="transcripts_DetailView_Save">
So those are the names I used in the inline javascript.
This simple technique has many possibilities. One click of this button could be used to set the values of multiple fields at the same time. Even better is the use of the custom control to set the value of a variable and then have a validate event read the value of that variable and carry out other operations accordingly since you can include almost anything in the validate events using xbasic.
It is also possible to have the javascript in the custom control call a javascript function defined elsewhere on the a5w page but the use of this inline javascript is appealing.
I have benefited greatly from what I have learned from others on this forum and I hope someone can make use of this.
Thanks,
Irwin
Comment